Buggy code:
public class TestBooleanMinShouldMatch extends LuceneTestCase { private static Directory index ; private static IndexReader r ; private static IndexSearcher s ; @ BeforeClass public static void beforeClass ( ) throws Exception { } @ AfterClass public static void afterClass ( ) throws Exception { } public void verifyNrHits ( Query q , int expected ) throws Exception { } public void testAllOptional ( ) throws Exception { } public void testOneReqAndSomeOptional ( ) throws Exception { } public void testSomeReqAndSomeOptional ( ) throws Exception { } public void testOneProhibAndSomeOptional ( ) throws Exception { } public void testSomeProhibAndSomeOptional ( ) throws Exception { } public void testOneReqOneProhibAndSomeOptional ( ) throws Exception { } public void testSomeReqOneProhibAndSomeOptional ( ) throws Exception { } public void testOneReqSomeProhibAndSomeOptional ( ) throws Exception { } public void testSomeReqSomeProhibAndSomeOptional ( ) throws Exception { } public void testMinHigherThenNumOptional ( ) throws Exception { } public void testMinEqualToNumOptional ( ) throws Exception { } public void testOneOptionalEqualToMin ( ) throws Exception { } public void testNoOptionalButMin ( ) throws Exception { } public void testNoOptionalButMin2 ( ) throws Exception { } public void testRandomQueries ( ) throws Exception { String field = "data" ; String [ ] vals = new String [ ] { "1" , "2" , "3" , "4" , "5" , "6" , "A" , "Z" , "B" , "Y" , "Z" , "X" , "foo" } ; int maxLev = 4 ; TestBoolean2 . Callback minNrCB = new TestBoolean2 . Callback ( ) { public void postCreate ( BooleanQuery q ) { BooleanClause [ ] c = q . getClauses ( ) ; int opt = 0 ; for ( int i = 0 ; i < ( c . length ) ; i ++ ) { if ( ( c [ i ] . getOccur ( ) ) == ( Occur . SHOULD ) ) opt ++ ; } q . setMinimumNumberShouldMatch ( random . nextInt ( ( opt + 2 ) ) ) ; } } ; int num = atLeast ( 10 ) ; for ( int i = 0 ; i < num ; i ++ ) { int lev = random . nextInt ( maxLev ) ; final long seed = random . nextLong ( ) ; BooleanQuery q1 = TestBoolean2 . randBoolQuery ( new Random ( seed ) , true , lev , field , vals , null ) ; BooleanQuery q2 = TestBoolean2 . randBoolQuery ( new Random ( seed ) , true , lev , field , vals , null ) ; minNrCB . postCreate ( q2 ) ; TopDocs top1 = TestBooleanMinShouldMatch . s . search ( q1 , null , 100 ) ; TopDocs top2 = TestBooleanMinShouldMatch . s . search ( q2 , null , 100 ) ; if ( i < 100 ) { QueryUtils . check ( random , q1 , TestBooleanMinShouldMatch . s ) ; QueryUtils . check ( random , q2 , TestBooleanMinShouldMatch . s ) ; } if ( ( top2 . totalHits ) > ( top1 . totalHits ) ) { fail ( ( ( ( ( "Constrained<seq2seq4repair_space>results<seq2seq4repair_space>not<seq2seq4repair_space>a<seq2seq4repair_space>subset:\n" + ( CheckHits . topdocsString ( top1 , 0 , 0 ) ) ) + ( CheckHits . topdocsString ( top2 , 0 , 0 ) ) ) + "for<seq2seq4repair_space>query:" ) + ( q2 . toString ( ) ) ) ) ; } for ( int hit = 0 ; hit < ( top2 . totalHits ) ; hit ++ ) { int id = top2 . scoreDocs [ hit ] . doc ; float score = top2 . scoreDocs [ hit ] . score ; boolean found = false ; for ( int other = 0 ; other < ( top1 . totalHits ) ; other ++ ) { if ( ( top1 . scoreDocs [ other ] . doc ) == id ) { found = true ; float otherScore = top1 . scoreDocs [ other ] . score ; <START_BUG> assertEquals ( ( ( ( ( ( ( "Doc<seq2seq4repair_space>" + id ) + "<seq2seq4repair_space>scores<seq2seq4repair_space>don\'t<seq2seq4repair_space>match\n" ) + ( CheckHits . topdocsString ( top1 , 0 , 0 ) ) ) + ( CheckHits . topdocsString ( top2 , 0 , 0 ) ) ) + "for<seq2seq4repair_space>query:" ) + ( q2 . toString ( ) ) ) , score , otherScore , 1.0E-6F ) ; <END_BUG> } } if ( ! found ) fail ( ( ( ( ( ( ( "Doc<seq2seq4repair_space>" + id ) + "<seq2seq4repair_space>not<seq2seq4repair_space>found\n" ) + ( CheckHits . topdocsString ( top1 , 0 , 0 ) ) ) + ( CheckHits . topdocsString ( top2 , 0 , 0 ) ) ) + "for<seq2seq4repair_space>query:" ) + ( q2 . toString ( ) ) ) ) ; } } } protected void printHits ( String test , ScoreDoc [ ] h , IndexSearcher searcher ) throws Exception { } }

Fix:
assertEquals ( ( ( ( ( ( ( "Doc<seq2seq4repair_space>" + id ) + "<seq2seq4repair_space>scores<seq2seq4repair_space>don\'t<seq2seq4repair_space>match\n" ) + ( CheckHits . topdocsString ( top1 , 0 , 0 ) ) ) + ( CheckHits . topdocsString ( top2 , 0 , 0 ) ) ) + "for<seq2seq4repair_space>query:" ) + ( q2 . toString ( ) ) ) , score , otherScore , CheckHits . explainToleranceDelta ( score , otherScore ) ) ;