#include "src/tint/lang/core/constant/eval_test.h"
#include "src/tint/lang/wgsl/builtin_fn.h"
#include "src/tint/utils/result/result.h"
#if TINT_BUILD_WGSL_READER
#include "src/tint/lang/wgsl/reader/reader.h"
#endif
usingnamespacetint::core::fluent_types;
usingnamespacetint::core::number_suffixes;
HasSubstr;
namespace tint::core::constant::test {
namespace {
struct Case { … };
struct ErrorCase { … };
Case C(Value lhs, Value rhs, Value expected) { … }
template <typename T, typename U, typename V, typename = std::enable_if_t<!IsValue<T>>>
Case C(T lhs, U rhs, V expected) { … }
Case E(Value lhs, Value rhs, std::string error) { … }
template <typename T, typename U, typename = std::enable_if_t<!IsValue<T>>>
Case E(T lhs, U rhs, std::string error) { … }
static std::ostream& operator<<(std::ostream& o, const Case& c) { … }
std::ostream& operator<<(std::ostream& o, const ErrorCase& c) { … }
ConstEvalBinaryOpTest;
TEST_P(ConstEvalBinaryOpTest, Test) { … }
INSTANTIATE_TEST_SUITE_P(…);
template <typename T>
std::vector<Case> OpAddIntCases() { … }
template <typename T>
std::vector<Case> OpAddFloatCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
template <typename T>
std::vector<Case> OpSubIntCases() { … }
template <typename T>
std::vector<Case> OpSubFloatCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
template <typename T>
std::vector<Case> OpMulScalarCases() { … }
template <typename T>
std::vector<Case> OpMulVecCases() { … }
template <typename T>
std::vector<Case> OpMulMatCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
template <typename T>
std::vector<Case> OpDivIntCases() { … }
template <typename T>
std::vector<Case> OpDivFloatCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
template <typename T>
std::vector<Case> OpModCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
template <typename T, bool equals>
std::vector<Case> OpEqualCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
template <typename T, bool less_than>
std::vector<Case> OpLessThanCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
template <typename T, bool greater_than>
std::vector<Case> OpGreaterThanCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
struct AbstractFloatVectorCompareCase { … };
ConstEvalBinaryOpAbstractFloatVectorCompareTest;
TEST_P(ConstEvalBinaryOpAbstractFloatVectorCompareTest, Test) { … }
INSTANTIATE_TEST_SUITE_P(…);
static std::vector<Case> OpLogicalAndCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
static std::vector<Case> OpLogicalOrCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
static std::vector<Case> OpAndBoolCases() { … }
template <typename T>
std::vector<Case> OpAndIntCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
static std::vector<Case> OpOrBoolCases() { … }
template <typename T>
std::vector<Case> OpOrIntCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(ConstEvalTest, NotAndOrOfVecs) { … }
template <typename T>
std::vector<Case> XorCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
template <typename T>
std::vector<Case> ShiftLeftCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(ConstEvalTest, BinaryAbstractAddOverflow_AInt) { … }
TEST_F(ConstEvalTest, BinaryAbstractAddUnderflow_AInt) { … }
TEST_F(ConstEvalTest, BinaryAbstractAddOverflow_AFloat) { … }
TEST_F(ConstEvalTest, BinaryAbstractAddUnderflow_AFloat) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(ConstEvalTest, BinaryAbstractShiftLeftByNegativeValue_Error) { … }
TEST_F(ConstEvalTest, BinaryAbstractShiftLeftRemainsAbstract) { … }
ConstEvalShiftLeftConcreteGeqBitWidthError;
TEST_P(ConstEvalShiftLeftConcreteGeqBitWidthError, Test) { … }
INSTANTIATE_TEST_SUITE_P(…);
ConstEvalShiftLeftSignChangeError;
TEST_P(ConstEvalShiftLeftSignChangeError, Test) { … }
template <typename T>
std::vector<ErrorCase> ShiftLeftSignChangeErrorCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
template <typename T>
std::vector<Case> ShiftRightCases() { … }
INSTANTIATE_TEST_SUITE_P(…);
namespace LogicalShortCircuit {
static void ValidateAnd(const sem::Info& sem, const ast::BinaryExpression* binary) { … }
static void ValidateOr(const sem::Info& sem, const ast::BinaryExpression* binary) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Error_Unary) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Error_Unary) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Invalid_Binary) { … }
TEST_F(ConstEvalTest, NonShortCircuit_And_Invalid_Binary) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Error_Binary) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Invalid_Binary) { … }
TEST_F(ConstEvalTest, NonShortCircuit_Or_Invalid_Binary) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Error_Binary) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Invalid_Materialize) { … }
TEST_F(ConstEvalTest, NonShortCircuit_And_Invalid_Materialize) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Error_Materialize) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Invalid_Materialize) { … }
TEST_F(ConstEvalTest, NonShortCircuit_Or_Invalid_Materialize) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Error_Materialize) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Invalid_Index) { … }
TEST_F(ConstEvalTest, NonShortCircuit_And_Invalid_Index) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Error_Index) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Invalid_Index) { … }
TEST_F(ConstEvalTest, NonShortCircuit_Or_Invalid_Index) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Error_Index) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Invalid_Bitcast) { … }
TEST_F(ConstEvalTest, NonShortCircuit_And_Invalid_Bitcast) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Error_Bitcast) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Invalid_Bitcast) { … }
TEST_F(ConstEvalTest, NonShortCircuit_Or_Invalid_Bitcast) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Error_Bitcast) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Error_Init) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Error_Init) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Error_StructInit) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Error_StructInit) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Error_ArrayInit) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Error_ArrayInit) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Invalid_BuiltinCall) { … }
TEST_F(ConstEvalTest, NonShortCircuit_And_Invalid_BuiltinCall) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Error_BuiltinCall) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Invalid_BuiltinCall) { … }
TEST_F(ConstEvalTest, NonShortCircuit_Or_Invalid_BuiltinCall) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Error_BuiltinCall) { … }
#if TINT_BUILD_WGSL_READER
TEST_F(ConstEvalTest, ShortCircuit_And_Error_Literal) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Error_Literal) { … }
#endif
TEST_F(ConstEvalTest, ShortCircuit_And_Error_MemberAccess) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Error_MemberAccess) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_RHSConstDecl) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_RHSConstDecl) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_RHSLetDecl) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_RHSLetDecl) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_RHSVarDecl) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_RHSVarDecl) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_RHSRuntimeBuiltin) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_RHSRuntimeBuiltin) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_Error_Swizzle) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_Error_Swizzle) { … }
TEST_F(ConstEvalTest, ShortCircuit_And_MixedConstantAndRuntime) { … }
TEST_F(ConstEvalTest, ShortCircuit_Or_MixedConstantAndRuntime) { … }
#if TINT_BUILD_WGSL_READER
ConstEvalTestShortCircuit;
TEST_P(ConstEvalTestShortCircuit, Test) { … }
INSTANTIATE_TEST_SUITE_P(…);
#endif
}
}
}