Skip to content

Commit 918f900

Browse files
committed
Make DecayTests more robust using closeTo(..., Math.ulp(...)) instead of equalTo (to work with rounded values)
1 parent f943253 commit 918f900

File tree

1 file changed

+13
-13
lines changed
  • x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/score

1 file changed

+13
-13
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/score/DecayTests.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ private static List<TestCaseSupplier> intTestCase(
625625
),
626626
startsWith("DecayIntEvaluator["),
627627
DataType.DOUBLE,
628-
equalTo(expected)
628+
closeTo(expected, Math.ulp(expected))
629629
)
630630
)
631631
);
@@ -659,7 +659,7 @@ private static List<TestCaseSupplier> intRandomTestCases() {
659659
),
660660
startsWith("DecayIntEvaluator["),
661661
DataType.DOUBLE,
662-
equalTo(scoreScriptNumericResult)
662+
closeTo(scoreScriptNumericResult, Math.ulp(scoreScriptNumericResult))
663663
);
664664
}));
665665
}
@@ -699,7 +699,7 @@ private static List<TestCaseSupplier> longTestCase(
699699
),
700700
startsWith("DecayLongEvaluator["),
701701
DataType.DOUBLE,
702-
equalTo(expected)
702+
closeTo(expected, Math.ulp(expected))
703703
)
704704
)
705705
);
@@ -769,7 +769,7 @@ private static List<TestCaseSupplier> doubleTestCase(
769769
),
770770
startsWith("DecayDoubleEvaluator["),
771771
DataType.DOUBLE,
772-
equalTo(expected)
772+
closeTo(expected, Math.ulp(expected))
773773
)
774774
)
775775
);
@@ -803,7 +803,7 @@ private static List<TestCaseSupplier> doubleRandomTestCases() {
803803
),
804804
startsWith("DecayDoubleEvaluator["),
805805
DataType.DOUBLE,
806-
equalTo(scoreScriptNumericResult)
806+
closeTo(scoreScriptNumericResult, Math.ulp(scoreScriptNumericResult))
807807
);
808808
}));
809809
}
@@ -839,7 +839,7 @@ private static List<TestCaseSupplier> geoPointTestCase(
839839
),
840840
startsWith("DecayGeoPointEvaluator["),
841841
DataType.DOUBLE,
842-
equalTo(expected)
842+
closeTo(expected, Math.ulp(expected))
843843
)
844844
)
845845
);
@@ -867,7 +867,7 @@ private static List<TestCaseSupplier> geoPointTestCaseKeywordScale(
867867
),
868868
startsWith("DecayGeoPointEvaluator["),
869869
DataType.DOUBLE,
870-
equalTo(expected)
870+
closeTo(expected, Math.ulp(expected))
871871
)
872872
)
873873
);
@@ -901,7 +901,7 @@ private static List<TestCaseSupplier> geoPointRandomTestCases() {
901901
),
902902
startsWith("DecayGeoPointEvaluator["),
903903
DataType.DOUBLE,
904-
equalTo(scoreScriptNumericResult)
904+
closeTo(scoreScriptNumericResult, Math.ulp(scoreScriptNumericResult))
905905
);
906906
}));
907907
}
@@ -981,7 +981,7 @@ private static List<TestCaseSupplier> geoPointOffsetKeywordTestCase(
981981
),
982982
startsWith("DecayGeoPointEvaluator["),
983983
DataType.DOUBLE,
984-
equalTo(expected)
984+
closeTo(expected, Math.ulp(expected))
985985
)
986986
)
987987
);
@@ -1009,7 +1009,7 @@ private static List<TestCaseSupplier> cartesianPointTestCase(
10091009
),
10101010
startsWith("DecayCartesianPointEvaluator["),
10111011
DataType.DOUBLE,
1012-
equalTo(expected)
1012+
closeTo(expected, Math.ulp(expected))
10131013
)
10141014
)
10151015
);
@@ -1037,7 +1037,7 @@ private static List<TestCaseSupplier> datetimeTestCase(
10371037
),
10381038
startsWith("DecayDatetimeEvaluator["),
10391039
DataType.DOUBLE,
1040-
equalTo(expected)
1040+
closeTo(expected, Math.ulp(expected))
10411041
).withoutEvaluator()
10421042
)
10431043
);
@@ -1080,7 +1080,7 @@ private static List<TestCaseSupplier> datetimeRandomTestCases() {
10801080
),
10811081
startsWith("DecayDatetimeEvaluator["),
10821082
DataType.DOUBLE,
1083-
equalTo(scoreScriptNumericResult)
1083+
closeTo(scoreScriptNumericResult, Math.ulp(scoreScriptNumericResult))
10841084
);
10851085
}));
10861086
}
@@ -1122,7 +1122,7 @@ private static List<TestCaseSupplier> dateNanosTestCase(
11221122
),
11231123
startsWith("DecayDateNanosEvaluator["),
11241124
DataType.DOUBLE,
1125-
equalTo(expected)
1125+
closeTo(expected, Math.ulp(expected))
11261126
).withoutEvaluator()
11271127
)
11281128
);

0 commit comments

Comments
 (0)