Skip to content

Commit

Permalink
are these names better? I can't even tell, it's late and I'm tired
Browse files Browse the repository at this point in the history
  • Loading branch information
not-napoleon committed Dec 11, 2023
1 parent 4bbefd6 commit a3f45b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,14 @@ public static List<TestCaseSupplier> forBinaryNumericNotCasting(
);
}

public record StuffForNumericType(Number min, Number max, BinaryOperator<Number> expected, String evaluatorName) {}
public record NumericTypeTestConfig(Number min, Number max, BinaryOperator<Number> expected, String evaluatorName) {}

public record AllTheTypeSpecificSettings(StuffForNumericType intStuff, StuffForNumericType longStuff, StuffForNumericType doubleStuff) {
public StuffForNumericType get(DataType type) {
public record NumericTypeTestConfigs(
NumericTypeTestConfig intStuff,
NumericTypeTestConfig longStuff,
NumericTypeTestConfig doubleStuff
) {
public NumericTypeTestConfig get(DataType type) {
if (type == DataTypes.INTEGER) {
return intStuff;
}
Expand Down Expand Up @@ -317,7 +321,7 @@ private static List<TypedDataSupplier> getSuppliersForNumericType(DataType type,
}

public static List<TestCaseSupplier> forBinaryWithWidening(
AllTheTypeSpecificSettings typeStuff,
NumericTypeTestConfigs typeStuff,
String lhsName,
String rhsName,
List<String> warnings
Expand All @@ -328,7 +332,7 @@ public static List<TestCaseSupplier> forBinaryWithWidening(
for (DataType lhsType : numericTypes) {
for (DataType rhsType : numericTypes) {
DataType expected = widen(lhsType, rhsType);
StuffForNumericType expectedTypeStuff = typeStuff.get(expected);
NumericTypeTestConfig expectedTypeStuff = typeStuff.get(expected);
String evaluator = expectedTypeStuff.evaluatorName()
+ "["
+ lhsName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ public static Iterable<Object[]> parameters() {
List<TestCaseSupplier> suppliers = new ArrayList<>();
suppliers.addAll(
TestCaseSupplier.forBinaryWithWidening(
new TestCaseSupplier.AllTheTypeSpecificSettings(
new TestCaseSupplier.StuffForNumericType(
new TestCaseSupplier.NumericTypeTestConfigs(
new TestCaseSupplier.NumericTypeTestConfig(
(Integer.MIN_VALUE >> 1) - 1,
(Integer.MAX_VALUE >> 1) - 1,
(l, r) -> l.intValue() + r.intValue(),
"AddIntsEvaluator"
),
new TestCaseSupplier.StuffForNumericType(
new TestCaseSupplier.NumericTypeTestConfig(
(Long.MIN_VALUE >> 1) - 1,
(Long.MAX_VALUE >> 1) - 1,
(l, r) -> l.longValue() + r.longValue(),
"AddLongsEvaluator"
),
new TestCaseSupplier.StuffForNumericType(
new TestCaseSupplier.NumericTypeTestConfig(
Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY,
(l, r) -> l.doubleValue() + r.doubleValue(),
Expand Down

0 comments on commit a3f45b7

Please sign in to comment.