Skip to content

Commit

Permalink
[ESQL] Plumb through ranges and warnings for the casting to double te…
Browse files Browse the repository at this point in the history
…sts (#99452)

Add the warnings and range checking parameters to unary and binary casting to double test generators. I also moved the data type to the value supplier, which the binary case needed. That feels more right - that's what I was intending with TypedData to begin with, but our abstractions are still messy here.
  • Loading branch information
not-napoleon committed Sep 12, 2023
1 parent 403bcb3 commit e26dca4
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 163 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -51,9 +50,9 @@ public static Iterable<Object[]> parameters() {
);
// But strings that are shaped like versions do parse to valid versions
for (DataType inputType : EsqlDataTypes.types().stream().filter(EsqlDataTypes::isString).toList()) {
for (Map.Entry<String, Supplier<Object>> versionGen : TestCaseSupplier.versionCases(inputType.typeName() + " ")) {
suppliers.add(new TestCaseSupplier(versionGen.getKey(), List.of(inputType), () -> {
BytesRef encodedVersion = (BytesRef) versionGen.getValue().get();
for (TestCaseSupplier.TypedDataSupplier versionGen : TestCaseSupplier.versionCases(inputType.typeName() + " ")) {
suppliers.add(new TestCaseSupplier(versionGen.name(), List.of(inputType), () -> {
BytesRef encodedVersion = (BytesRef) versionGen.supplier().get();
TestCaseSupplier.TypedData typed = new TestCaseSupplier.TypedData(
new BytesRef(new Version(encodedVersion).toString()),
inputType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public static Iterable<Object[]> parameters() {
"val",
Math::acos,
Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY
Double.POSITIVE_INFINITY,
List.of()
);
return parameterSuppliersFromTypedData(errorsForCasesWithoutExamples(anyNullIsNull(true, suppliers)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public static Iterable<Object[]> parameters() {
"val",
Math::asin,
Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY
Double.POSITIVE_INFINITY,
List.of()
);
return parameterSuppliersFromTypedData(errorsForCasesWithoutExamples(anyNullIsNull(true, suppliers)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@ public Atan2Tests(@Name("TestCase") Supplier<TestCaseSupplier.TestCase> testCase

@ParametersFactory
public static Iterable<Object[]> parameters() {
List<TestCaseSupplier> suppliers = TestCaseSupplier.forBinaryCastingToDouble("Atan2Evaluator", "y", "x", Math::atan2);
List<TestCaseSupplier> suppliers = TestCaseSupplier.forBinaryCastingToDouble(
"Atan2Evaluator",
"y",
"x",
Math::atan2,
Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY,
Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY,
List.of()
);
return parameterSuppliersFromTypedData(errorsForCasesWithoutExamples(anyNullIsNull(true, suppliers)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public static Iterable<Object[]> parameters() {
"val",
Math::atan,
Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY
Double.POSITIVE_INFINITY,
List.of()
);
return parameterSuppliersFromTypedData(errorsForCasesWithoutExamples(anyNullIsNull(true, suppliers)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public static Iterable<Object[]> parameters() {
"val",
Math::cos,
Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY
Double.POSITIVE_INFINITY,
List.of()
);
return parameterSuppliersFromTypedData(errorsForCasesWithoutExamples(anyNullIsNull(true, suppliers)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public static Iterable<Object[]> parameters() {
"val",
Math::cosh,
Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY
Double.POSITIVE_INFINITY,
List.of()
);
return parameterSuppliersFromTypedData(errorsForCasesWithoutExamples(anyNullIsNull(true, suppliers)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public static Iterable<Object[]> parameters() {
"val",
Math::sin,
Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY
Double.POSITIVE_INFINITY,
List.of()
);
return parameterSuppliersFromTypedData(errorsForCasesWithoutExamples(anyNullIsNull(true, suppliers)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public static Iterable<Object[]> parameters() {
"val",
Math::sinh,
Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY
Double.POSITIVE_INFINITY,
List.of()
);
return parameterSuppliersFromTypedData(errorsForCasesWithoutExamples(anyNullIsNull(true, suppliers)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public static Iterable<Object[]> parameters() {
"val",
Math::tan,
Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY
Double.POSITIVE_INFINITY,
List.of()
);
return parameterSuppliersFromTypedData(errorsForCasesWithoutExamples(anyNullIsNull(true, suppliers)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public static Iterable<Object[]> parameters() {
"val",
Math::tanh,
Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY
Double.POSITIVE_INFINITY,
List.of()
);
return parameterSuppliersFromTypedData(errorsForCasesWithoutExamples(anyNullIsNull(true, suppliers)));
}
Expand Down

0 comments on commit e26dca4

Please sign in to comment.