diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc index 21e6170f02..4b0ff0b92f 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -349,9 +349,9 @@ 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}, + E({T(1.1)}, "12:34 error: atanh must be called with a value in the range (-1 .. 1) (exclusive)"), - E({-1.1_a}, + E({-T(1.1)}, "12:34 error: atanh must be called with a value in the range (-1 .. 1) (exclusive)"), }; } @@ -375,9 +375,9 @@ std::vector AcosCases() { // Vector tests C({Vec(T(1.0), -T(1.0))}, Vec(T(0), kPi)).FloatComp(), - E({1.1_a}, + E({T(1.1)}, "12:34 error: acos must be called with a value in the range [-1 .. 1] (inclusive)"), - E({-1.1_a}, + E({-T(1.1)}, "12:34 error: acos must be called with a value in the range [-1 .. 1] (inclusive)"), }; } @@ -399,8 +399,8 @@ std::vector AcoshCases() { 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"), + E({-T(1.1)}, "12:34 error: acosh must be called with a value >= 1.0"), + E({T(0)}, "12:34 error: acosh must be called with a value >= 1.0"), }; } INSTANTIATE_TEST_SUITE_P( // @@ -424,9 +424,9 @@ 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}, + E({T(1.1)}, "12:34 error: asin must be called with a value in the range [-1 .. 1] (inclusive)"), - E({-1.1_a}, + E({-T(1.1)}, "12:34 error: asin must be called with a value in the range [-1 .. 1] (inclusive)"), }; } @@ -1452,6 +1452,10 @@ INSTANTIATE_TEST_SUITE_P( // template std::vector SmoothstepCases() { + auto error_msg = [](auto a, const char* op, auto b) { + return "12:34 error: " + OverflowErrorMessage(a, op, b) + R"( +12:34 note: when calculating smoothstep)"; + }; return { // t == 0 C({T(4), T(6), T(2)}, T(0)), @@ -1462,6 +1466,13 @@ std::vector SmoothstepCases() { // Vector tests C({Vec(T(4), T(4)), Vec(T(6), T(6)), Vec(T(2), T(8))}, Vec(T(0), T(1))), + + // `x - low` underflows + E({T::Highest(), T(1), T::Lowest()}, error_msg(T::Lowest(), "-", T::Highest())), + // `high - low` underflows + E({T::Highest(), T::Lowest(), T(0)}, error_msg(T::Lowest(), "-", T::Highest())), + // Divide by zero on `(x - low) / (high - low)` + E({T(0), T(0), T(0)}, error_msg(T(0), "/", T(0))), }; } INSTANTIATE_TEST_SUITE_P( // @@ -1472,68 +1483,6 @@ INSTANTIATE_TEST_SUITE_P( // SmoothstepCases(), SmoothstepCases())))); -template -std::vector SmoothstepAFloatErrorCases() { - auto error_msg = [](auto a, const char* op, auto b) { - return "12:34 error: " + OverflowErrorMessage(a, op, b) + R"( -12:34 note: when calculating smoothstep)"; - }; - - return {// `x - low` underflows - E({T::Highest(), T(1), T::Lowest()}, error_msg(T::Lowest(), "-", T::Highest())), - // `high - low` underflows - E({T::Highest(), T::Lowest(), T(0)}, error_msg(T::Lowest(), "-", T::Highest())), - // Divid by zero on `(x - low) / (high - low)` - E({T(0), T(0), T(0)}, error_msg(T(0), "/", T(0)))}; -} -INSTANTIATE_TEST_SUITE_P( // - SmoothstepAFloatError, - ResolverConstEvalBuiltinTest, - testing::Combine(testing::Values(sem::BuiltinType::kSmoothstep), - testing::ValuesIn(SmoothstepAFloatErrorCases()))); - -template -std::vector SmoothstepF16ErrorCases() { - auto error_msg = [](auto a, const char* op, auto b) { - return "12:34 error: " + OverflowErrorMessage(a, op, b) + R"( -12:34 note: when calculating smoothstep)"; - }; - - return {// `x - low` underflows - E({T::Highest(), T(1), T::Lowest()}, error_msg(T::Lowest(), "-", T::Highest())), - // `high - low` underflows - E({T::Highest(), T::Lowest(), T(0)}, error_msg(T::Lowest(), "-", T::Highest())), - // Divid by zero on `(x - low) / (high - low)` - E({T(0), T(0), T(0)}, error_msg(T(0), "/", T(0)))}; -} -// TODO(crbug.com/tint/1581): Enable when non-abstract math is checked. -INSTANTIATE_TEST_SUITE_P( // - DISABLED_SmoothstepF16Error, - ResolverConstEvalBuiltinTest, - testing::Combine(testing::Values(sem::BuiltinType::kSmoothstep), - testing::ValuesIn(SmoothstepF16ErrorCases()))); - -template -std::vector SmoothstepF32ErrorCases() { - auto error_msg = [](auto a, const char* op, auto b) { - return "12:34 error: " + OverflowErrorMessage(a, op, b) + R"( -12:34 note: when calculating smoothstep)"; - }; - - return {// `x - low` underflows - E({T::Highest(), T(1), T::Lowest()}, error_msg(T::Lowest(), "-", T::Highest())), - // `high - low` underflows - E({T::Highest(), T::Lowest(), T(0)}, error_msg(T::Lowest(), "-", T::Highest())), - // Divid by zero on `(x - low) / (high - low)` - E({T(0), T(0), T(0)}, error_msg(T(0), "/", T(0)))}; -} -// TODO(crbug.com/tint/1581): Enable when non-abstract math is checked. -INSTANTIATE_TEST_SUITE_P( // - DISABLED_SmoothstepF32Error, - ResolverConstEvalBuiltinTest, - testing::Combine(testing::Values(sem::BuiltinType::kSmoothstep), - testing::ValuesIn(SmoothstepF32ErrorCases()))); - template std::vector StepCases() { return {