diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc index c7ae431fb8..df0c6a9d1d 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -190,7 +190,7 @@ INSTANTIATE_TEST_SUITE_P( // C({1.0_a, 0_a}, kPiOver2), }))); -template +template std::vector AbsCases() { std::vector cases = { C({T(0)}, T(0)), @@ -200,7 +200,6 @@ std::vector AbsCases() { // Vector tests C({Vec(T(2.0), T::Highest())}, Vec(T(2.0), T::Highest())), }; - ConcatIntoIf>( cases, std::vector{ @@ -215,27 +214,18 @@ std::vector AbsCases() { C({Vec(T(0), Negate(T(0)))}, Vec(T(0), T(0))), C({Vec(Negate(T(2.0)), T(2.0), T::Highest())}, Vec(T(2.0), T(2.0), T::Highest())), }); - - ConcatIntoIf(cases, std::vector{ - C({Negate(T::Inf())}, T::Inf()), - C({T::Inf()}, T::Inf()), - C({T::NaN()}, T::NaN()), - C({Vec(Negate(T::Inf()), T::Inf(), T::NaN())}, - Vec(T::Inf(), T::Inf(), T::NaN())), - }); - return cases; } INSTANTIATE_TEST_SUITE_P( // Abs, ResolverConstEvalBuiltinTest, testing::Combine(testing::Values(sem::BuiltinType::kAbs), - testing::ValuesIn(Concat(AbsCases(), // - AbsCases(), - AbsCases(), - AbsCases(), - AbsCases(), - AbsCases())))); + testing::ValuesIn(Concat(AbsCases(), // + AbsCases(), + AbsCases(), + AbsCases(), + AbsCases(), + AbsCases())))); static std::vector AllCases() { return { @@ -295,9 +285,9 @@ INSTANTIATE_TEST_SUITE_P( // ResolverConstEvalBuiltinTest, testing::Combine(testing::Values(sem::BuiltinType::kAny), testing::ValuesIn(AnyCases()))); -template +template std::vector Atan2Cases() { - std::vector cases = { + return { // If y is +/-0 and x is negative or -0, +/-PI is returned C({T(0.0), -T(0.0)}, kPi).PosOrNeg().FloatComp(), @@ -318,59 +308,18 @@ std::vector Atan2Cases() { .FloatComp(), C({Vec(T(1.0), T(1.0)), Vec(T(0.0), -T(0.0))}, Vec(kPiOver2, kPiOver2)).FloatComp(), }; - - ConcatIntoIf( // - cases, std::vector{ - // If y is +/-INF and x is finite, +/-PI/2 is returned - C({T::Inf(), T(0.0)}, kPiOver2).PosOrNeg().FloatComp(), - C({-T::Inf(), T(0.0)}, kPiOver2).PosOrNeg().FloatComp(), - - // If y is +/-INF and x is -INF, +/-3PI/4 is returned - C({T::Inf(), -T::Inf()}, k3PiOver4).PosOrNeg().FloatComp(), - C({-T::Inf(), -T::Inf()}, k3PiOver4).PosOrNeg().FloatComp(), - - // If y is +/-INF and x is +INF, +/-PI/4 is returned - C({T::Inf(), T::Inf()}, kPiOver4).PosOrNeg().FloatComp(), - C({-T::Inf(), T::Inf()}, kPiOver4).PosOrNeg().FloatComp(), - - // If x is -INF and y is finite and positive, +PI is returned - C({T(0.0), -T::Inf()}, kPi).FloatComp(), - - // If x is -INF and y is finite and negative, -PI is returned - C({-T(0.0), -T::Inf()}, -kPi).FloatComp(), - - // If x is +INF and y is finite and positive, +0 is returned - C({T(0.0), T::Inf()}, T(0.0)), - - // If x is +INF and y is finite and negative, -0 is returned - C({-T(0.0), T::Inf()}, -T(0.0)), - - // If either x is NaN or y is NaN, NaN is returned - C({T::NaN(), T(0.0)}, T::NaN()), - C({T(0.0), T::NaN()}, T::NaN()), - C({T::NaN(), T::NaN()}, T::NaN()), - - // Vector tests - C({Vec(T::Inf(), -T::Inf(), T::Inf(), -T::Inf()), // - Vec(T(0.0), T(0.0), -T::Inf(), -T::Inf())}, // - Vec(kPiOver2, kPiOver2, k3PiOver4, k3PiOver4)) - .PosOrNeg() - .FloatComp(), - }); - - return cases; } INSTANTIATE_TEST_SUITE_P( // Atan2, ResolverConstEvalBuiltinTest, testing::Combine(testing::Values(sem::BuiltinType::kAtan2), - testing::ValuesIn(Concat(Atan2Cases(), // - Atan2Cases(), - Atan2Cases())))); + testing::ValuesIn(Concat(Atan2Cases(), // + Atan2Cases(), + Atan2Cases())))); -template +template std::vector AtanCases() { - std::vector cases = { + return { C({T(1.0)}, kPiOver4).FloatComp(), C({-T(1.0)}, -kPiOver4).FloatComp(), @@ -380,35 +329,18 @@ std::vector AtanCases() { // Vector tests C({Vec(T(0.0), T(1.0), -T(1.0))}, Vec(T(0.0), kPiOver4, -kPiOver4)).FloatComp(), }; - - ConcatIntoIf( // - cases, std::vector{ - // If i is +/-INF, +/-PI/2 is returned - C({T::Inf()}, kPiOver2).PosOrNeg().FloatComp(), - C({-T::Inf()}, -kPiOver2).FloatComp(), - - // If i is NaN, NaN is returned - C({T::NaN()}, T::NaN()), - - // Vector tests - C({Vec(T::Inf(), -T::Inf(), T::Inf(), -T::Inf())}, // - Vec(kPiOver2, -kPiOver2, kPiOver2, -kPiOver2)) - .FloatComp(), - }); - - return cases; } INSTANTIATE_TEST_SUITE_P( // Atan, ResolverConstEvalBuiltinTest, testing::Combine(testing::Values(sem::BuiltinType::kAtan), - testing::ValuesIn(Concat(AtanCases(), // - AtanCases(), - AtanCases())))); + testing::ValuesIn(Concat(AtanCases(), // + AtanCases(), + AtanCases())))); -template +template std::vector AtanhCases() { - std::vector cases = { + return { // If i is +/-0, +/-0 is returned C({T(0.0)}, T(0.0)).PosOrNeg(), @@ -416,43 +348,24 @@ std::vector AtanhCases() { // Vector tests C({Vec(T(0.0), T(0.9), -T(0.9))}, Vec(T(0.0), T(1.4722193), -T(1.4722193))).FloatComp(), + + E({1.1_a}, + "12:34 error: atanh must be called with a value in the range (-1 .. 1) (exclusive)"), + E({-1.1_a}, + "12:34 error: atanh must be called with a value in the range (-1 .. 1) (exclusive)"), }; - - ConcatIntoIf( // - cases, - std::vector{ - E({1.1_a}, - "12:34 error: atanh must be called with a value in the range (-1 .. 1) (exclusive)"), - E({-1.1_a}, - "12:34 error: atanh must be called with a value in the range (-1 .. 1) (exclusive)"), - E({T::Inf()}, - "12:34 error: atanh must be called with a value in the range (-1 .. 1) (exclusive)"), - E({-T::Inf()}, - "12:34 error: atanh must be called with a value in the range (-1 .. 1) (exclusive)"), - }); - - ConcatIntoIf( // - cases, std::vector{ - // If i is NaN, NaN is returned - C({T::NaN()}, T::NaN()), - - // Vector tests - C({Vec(T::NaN(), T::NaN())}, Vec(T::NaN(), T::NaN())).FloatComp(), - }); - - return cases; } INSTANTIATE_TEST_SUITE_P( // Atanh, ResolverConstEvalBuiltinTest, testing::Combine(testing::Values(sem::BuiltinType::kAtanh), - testing::ValuesIn(Concat(AtanhCases(), // - AtanhCases(), - AtanhCases())))); + testing::ValuesIn(Concat(AtanhCases(), // + AtanhCases(), + AtanhCases())))); -template +template std::vector AcosCases() { - std::vector cases = { + return { // If i is +/-0, +/-0 is returned C({T(0.87758256189)}, T(0.5)).FloatComp(), @@ -461,70 +374,46 @@ std::vector AcosCases() { // Vector tests C({Vec(T(1.0), -T(1.0))}, Vec(T(0), kPi)).FloatComp(), + + E({1.1_a}, + "12:34 error: acos must be called with a value in the range [-1 .. 1] (inclusive)"), + E({-1.1_a}, + "12:34 error: acos must be called with a value in the range [-1 .. 1] (inclusive)"), }; - - ConcatIntoIf( // - cases, - std::vector{ - E({1.1_a}, - "12:34 error: acos must be called with a value in the range [-1 .. 1] (inclusive)"), - E({-1.1_a}, - "12:34 error: acos must be called with a value in the range [-1 .. 1] (inclusive)"), - E({T::Inf()}, - "12:34 error: acos must be called with a value in the range [-1 .. 1] (inclusive)"), - E({-T::Inf()}, - "12:34 error: acos must be called with a value in the range [-1 .. 1] (inclusive)"), - }); - - ConcatIntoIf( // - cases, std::vector{ - // If i is NaN, NaN is returned - C({T::NaN()}, T::NaN()), - - // Vector tests - C({Vec(T::NaN(), T::NaN())}, Vec(T::NaN(), T::NaN())), - }); - - return cases; } INSTANTIATE_TEST_SUITE_P( // Acos, ResolverConstEvalBuiltinTest, testing::Combine(testing::Values(sem::BuiltinType::kAcos), - testing::ValuesIn(Concat(AcosCases(), // - AcosCases(), - AcosCases())))); + testing::ValuesIn(Concat(AcosCases(), // + AcosCases(), + AcosCases())))); -template +template std::vector AcoshCases() { - std::vector cases = { + return { C({T(1.0)}, T(0.0)), C({T(11.5919532755)}, kPi).FloatComp(), // Vector tests C({Vec(T(1.0), T(11.5919532755))}, Vec(T(0), kPi)).FloatComp(), + + E({T::Smallest()}, "12:34 error: acosh must be called with a value >= 1.0"), + E({-1.1_a}, "12:34 error: acosh must be called with a value >= 1.0"), + E({0_a}, "12:34 error: acosh must be called with a value >= 1.0"), }; - - ConcatIntoIf( // - cases, std::vector{ - E({T::Smallest()}, "12:34 error: acosh must be called with a value >= 1.0"), - E({-1.1_a}, "12:34 error: acosh must be called with a value >= 1.0"), - E({0_a}, "12:34 error: acosh must be called with a value >= 1.0"), - }); - - return cases; } INSTANTIATE_TEST_SUITE_P( // Acosh, ResolverConstEvalBuiltinTest, testing::Combine(testing::Values(sem::BuiltinType::kAcosh), - testing::ValuesIn(Concat(AcoshCases(), // - AcoshCases(), - AcoshCases())))); + testing::ValuesIn(Concat(AcoshCases(), // + AcoshCases(), + AcoshCases())))); -template +template std::vector AsinCases() { - std::vector cases = { + return { // If i is +/-0, +/-0 is returned C({T(0.0)}, T(0.0)), C({-T(0.0)}, -T(0.0)), @@ -534,43 +423,24 @@ std::vector AsinCases() { // Vector tests C({Vec(T(0.0), T(1.0), -T(1.0))}, Vec(T(0.0), kPiOver2, -kPiOver2)).FloatComp(), + + E({1.1_a}, + "12:34 error: asin must be called with a value in the range [-1 .. 1] (inclusive)"), + E({-1.1_a}, + "12:34 error: asin must be called with a value in the range [-1 .. 1] (inclusive)"), }; - - ConcatIntoIf( // - cases, - std::vector{ - E({1.1_a}, - "12:34 error: asin must be called with a value in the range [-1 .. 1] (inclusive)"), - E({-1.1_a}, - "12:34 error: asin must be called with a value in the range [-1 .. 1] (inclusive)"), - E({T::Inf()}, - "12:34 error: asin must be called with a value in the range [-1 .. 1] (inclusive)"), - E({-T::Inf()}, - "12:34 error: asin must be called with a value in the range [-1 .. 1] (inclusive)"), - }); - - ConcatIntoIf( // - cases, std::vector{ - // If i is NaN, NaN is returned - C({T::NaN()}, T::NaN()), - - // Vector tests - C({Vec(T::NaN(), T::NaN())}, Vec(T::NaN(), T::NaN())).FloatComp(), - }); - - return cases; } INSTANTIATE_TEST_SUITE_P( // Asin, ResolverConstEvalBuiltinTest, testing::Combine(testing::Values(sem::BuiltinType::kAsin), - testing::ValuesIn(Concat(AsinCases(), // - AsinCases(), - AsinCases())))); + testing::ValuesIn(Concat(AsinCases(), // + AsinCases(), + AsinCases())))); -template +template std::vector AsinhCases() { - std::vector cases = { + return { // If i is +/-0, +/-0 is returned C({T(0.0)}, T(0.0)), C({-T(0.0)}, -T(0.0)), @@ -583,34 +453,18 @@ std::vector AsinhCases() { Vec(T(0.0), T(0.8088669356278), -T(1.4436354751788))) .FloatComp(), }; - - ConcatIntoIf( // - cases, std::vector{ - // If i is +/- INF, +/-INF is returned - C({T::Inf()}, T::Inf()), - C({-T::Inf()}, -T::Inf()), - - // If i is NaN, NaN is returned - C({T::NaN()}, T::NaN()), - - // Vector tests - C({Vec(T::Inf(), T::NaN(), -T::Inf())}, // - Vec(T::Inf(), T::NaN(), -T::Inf())), - }); - - return cases; } INSTANTIATE_TEST_SUITE_P( // Asinh, ResolverConstEvalBuiltinTest, testing::Combine(testing::Values(sem::BuiltinType::kAsinh), - testing::ValuesIn(Concat(AsinhCases(), // - AsinhCases(), - AsinhCases())))); + testing::ValuesIn(Concat(AsinhCases(), // + AsinhCases(), + AsinhCases())))); -template +template std::vector CeilCases() { - std::vector cases = { + return { C({T(0)}, T(0)), C({-T(0)}, -T(0)), C({-T(1.5)}, -T(1.0)), @@ -620,24 +474,13 @@ std::vector CeilCases() { C({Vec(T(0), T(1.5), -T(1.5))}, Vec(T(0), T(2.0), -T(1.0))), }; - - ConcatIntoIf( - cases, std::vector{ - C({-T::Inf()}, -T::Inf()), - C({T::Inf()}, T::Inf()), - C({T::NaN()}, T::NaN()), - C({Vec(-T::Inf(), T::Inf(), T::NaN())}, Vec(-T::Inf(), T::Inf(), T::NaN())), - }); - - return cases; } INSTANTIATE_TEST_SUITE_P( // Ceil, ResolverConstEvalBuiltinTest, - testing::Combine(testing::Values(sem::BuiltinType::kCeil), - testing::ValuesIn(Concat(CeilCases(), - CeilCases(), - CeilCases())))); + testing::Combine( + testing::Values(sem::BuiltinType::kCeil), + testing::ValuesIn(Concat(CeilCases(), CeilCases(), CeilCases())))); template std::vector ClampCases() { @@ -1044,9 +887,9 @@ INSTANTIATE_TEST_SUITE_P( // testing::ValuesIn(Concat(FirstTrailingBitCases(), // FirstTrailingBitCases())))); -template +template std::vector FloorCases() { - std::vector cases = { + return { C({T(0)}, T(0)), C({-T(0)}, -T(0)), C({-T(1.5)}, -T(2.0)), @@ -1056,24 +899,14 @@ std::vector FloorCases() { C({Vec(T(0), T(1.5), -T(1.5))}, Vec(T(0), T(1.0), -T(2.0))), }; - - ConcatIntoIf( - cases, std::vector{ - C({-T::Inf()}, -T::Inf()), - C({T::Inf()}, T::Inf()), - C({T::NaN()}, T::NaN()), - C({Vec(-T::Inf(), T::Inf(), T::NaN())}, Vec(-T::Inf(), T::Inf(), T::NaN())), - }); - - return cases; } INSTANTIATE_TEST_SUITE_P( // Floor, ResolverConstEvalBuiltinTest, testing::Combine(testing::Values(sem::BuiltinType::kFloor), - testing::ValuesIn(Concat(FloorCases(), - FloorCases(), - FloorCases())))); + testing::ValuesIn(Concat(FloorCases(), // + FloorCases(), + FloorCases())))); template std::vector InsertBitsCases() {