I worry about real code (e.g. scorers) doing this too. Its also difficult to debug when a test does this: I think we had this problem with calling TermsEnum.next() after the enumeration was over before, and it looks really scary.
We already have reader wrapping in LuceneTestcase.maybeWrapReader. I think it would be nice to have an AssertingReader added here: an FIR that wrapped the Fields instance and asserted all these various contracts we have in place to catch bad consumers. On Wed, Jul 11, 2012 at 10:36 AM, <[email protected]> wrote: > Author: mikemccand > Date: Wed Jul 11 14:36:06 2012 > New Revision: 1360205 > > URL: http://svn.apache.org/viewvc?rev=1360205&view=rev > Log: > fix test: don't call .nextDoc() if the enum had already returned NO_MORE_DOCS > > Modified: > > lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java > > Modified: > lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java > URL: > http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java?rev=1360205&r1=1360204&r2=1360205&view=diff > ============================================================================== > --- > lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java > (original) > +++ > lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java > Wed Jul 11 14:36:06 2012 > @@ -559,6 +559,7 @@ public class TestCodecs extends LuceneTe > } > assertNotNull(docs); > int upto2 = -1; > + boolean ended = false; > while(upto2 < term.docs.length-1) { > // Maybe skip: > final int left = term.docs.length-upto2; > @@ -574,6 +575,7 @@ public class TestCodecs extends LuceneTe > if (doc == DocIdSetIterator.NO_MORE_DOCS) { > // skipped past last doc > assert upto2 == term.docs.length-1; > + ended = true; > break; > } else { > // skipped to next doc > @@ -597,7 +599,9 @@ public class TestCodecs extends LuceneTe > } > } > > - assertEquals(DocIdSetIterator.NO_MORE_DOCS, docs.nextDoc()); > + if (!ended) { > + assertEquals(DocIdSetIterator.NO_MORE_DOCS, docs.nextDoc()); > + } > } > upto++; > > > -- lucidimagination.com --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
