Apache Lucene open-source search software
Improve test and address more test failures.
Adrien Grand3f71b54c47ad
diff --git a/lucene/core/src/java/org/apache/lucene/search/ScorerUtil.java b/lucene/core/src/java/org/apache/lucene/search/ScorerUtil.javaindex d26dd5af67b..bf1b145bc6d 100644--- a/lucene/core/src/java/org/apache/lucene/search/ScorerUtil.java+++ b/lucene/core/src/java/org/apache/lucene/search/ScorerUtil.java@@ -130,9 +130,7 @@ class ScorerUtil {// note: we want the float ulp in order to converge faster, not the double ulpdouble subtraction = Math.ulp(minCompetitiveScore);while (minRequiredScore > 0- && (float)- MathUtil.sumUpperBound(- minRequiredScore - subtraction + maxRemainingScore, numScorers)+ && (float) MathUtil.sumUpperBound(minRequiredScore + maxRemainingScore, numScorers)>= minCompetitiveScore) {minRequiredScore -= subtraction;}diff --git a/lucene/core/src/test/org/apache/lucene/search/TestScorerUtil.java b/lucene/core/src/test/org/apache/lucene/search/TestScorerUtil.javaindex 360d797953d..fb3f031ef8d 100644--- a/lucene/core/src/test/org/apache/lucene/search/TestScorerUtil.java+++ b/lucene/core/src/test/org/apache/lucene/search/TestScorerUtil.java@@ -96,7 +96,7 @@ public class TestScorerUtil extends LuceneTestCase {}public void testMinRequiredScore() {- int iters = atLeast(100);+ int iters = atLeast(10000);for (int iter = 0; iter < iters; iter++) {double maxRemainingScore = random().nextDouble();float minCompetitiveScore = random().nextFloat();@@ -107,9 +107,13 @@ public class TestScorerUtil extends LuceneTestCase {if (minCompetitiveScore < maxRemainingScore) {assertTrue(minRequiredScore <= 0);} else {- assertTrue(- (float) MathUtil.sumUpperBound(minRequiredScore + maxRemainingScore, numScorers)- <= minCompetitiveScore);+ // The value before minRequiredScore must not be able to produce a score >=+ // minCompetitiveScore.+ assertFalse(+ (float)+ MathUtil.sumUpperBound(+ Math.nextDown(minRequiredScore) + maxRemainingScore, numScorers)+ >= minCompetitiveScore);}// NOTE: we need to assert the internal while loop ends within an acceptable iterations. But