#include "src/tint/lang/wgsl/resolver/resolver.h"
#include "gmock/gmock.h"
#include "src/tint/lang/core/type/helper_test.h"
#include "src/tint/lang/core/type/sampled_texture.h"
#include "src/tint/lang/core/type/texture_dimension.h"
#include "src/tint/lang/wgsl/ast/assignment_statement.h"
#include "src/tint/lang/wgsl/ast/break_statement.h"
#include "src/tint/lang/wgsl/ast/builtin_texture_helper_test.h"
#include "src/tint/lang/wgsl/ast/call_statement.h"
#include "src/tint/lang/wgsl/ast/continue_statement.h"
#include "src/tint/lang/wgsl/ast/if_statement.h"
#include "src/tint/lang/wgsl/ast/loop_statement.h"
#include "src/tint/lang/wgsl/ast/return_statement.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
#include "src/tint/lang/wgsl/ast/switch_statement.h"
#include "src/tint/lang/wgsl/ast/unary_op_expression.h"
#include "src/tint/lang/wgsl/ast/variable_decl_statement.h"
#include "src/tint/lang/wgsl/resolver/resolver_helper_test.h"
#include "src/tint/lang/wgsl/sem/call.h"
#include "src/tint/lang/wgsl/sem/function.h"
#include "src/tint/lang/wgsl/sem/member_accessor_expression.h"
#include "src/tint/lang/wgsl/sem/statement.h"
#include "src/tint/lang/wgsl/sem/variable.h"
#include "src/tint/utils/text/string.h"
#include "src/tint/utils/text/string_stream.h"
ElementsAre;
HasSubstr;
namespace tint::resolver {
namespace {
usingnamespacetint::core::fluent_types;
usingnamespacetint::core::number_suffixes;
ExpressionList;
ResolverBuiltinTest;
struct BuiltinData { … };
inline std::ostream& operator<<(std::ostream& out, BuiltinData data) { … }
TEST_F(ResolverBuiltinTest, ModuleScopeUsage) { … }
TEST_F(ResolverBuiltinTest, SameOverloadReturnsSameCallTarget) { … }
namespace logical_builtin_tests {
ResolverBuiltinTest_BoolMethod;
TEST_P(ResolverBuiltinTest_BoolMethod, Scalar) { … }
TEST_P(ResolverBuiltinTest_BoolMethod, Vector) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(ResolverBuiltinTest, Select) { … }
TEST_F(ResolverBuiltinTest, Select_Error_NoParams) { … }
TEST_F(ResolverBuiltinTest, Select_Error_SelectorInt) { … }
TEST_F(ResolverBuiltinTest, Select_Error_Matrix) { … }
TEST_F(ResolverBuiltinTest, Select_Error_MismatchTypes) { … }
TEST_F(ResolverBuiltinTest, Select_Error_MismatchVectorSize) { … }
}
namespace array_builtin_tests {
ResolverBuiltinArrayTest;
TEST_F(ResolverBuiltinArrayTest, ArrayLength_Vector) { … }
TEST_F(ResolverBuiltinArrayTest, ArrayLength_Error_ArraySized) { … }
}
namespace float_builtin_tests {
struct BuiltinDataWithParamNum { … };
inline std::ostream& operator<<(std::ostream& out, BuiltinDataWithParamNum data) { … }
ResolverBuiltinTest_FloatBuiltin_IdenticalType;
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, Error_NoParams) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, OneParam_Scalar_f32) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, OneParam_Vector_f32) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, TwoParams_Scalar_f32) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, TwoParams_Vector_f32) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, ThreeParams_Scalar_f32) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, ThreeParams_Vector_f32) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, FourParams_Scalar_f32) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, FourParams_Vector_f32) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, OneParam_Scalar_f16) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, OneParam_Vector_f16) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, TwoParams_Scalar_f16) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, TwoParams_Vector_f16) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, ThreeParams_Scalar_f16) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, ThreeParams_Vector_f16) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, FourParams_Scalar_f16) { … }
TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, FourParams_Vector_f16) { … }
INSTANTIATE_TEST_SUITE_P(…);
ResolverBuiltinFloatTest;
TEST_F(ResolverBuiltinFloatTest, Cross_f32) { … }
TEST_F(ResolverBuiltinFloatTest, Cross_f16) { … }
TEST_F(ResolverBuiltinFloatTest, Cross_Error_NoArgs) { … }
TEST_F(ResolverBuiltinFloatTest, Cross_Error_Scalar) { … }
TEST_F(ResolverBuiltinFloatTest, Cross_Error_Vec3Int) { … }
TEST_F(ResolverBuiltinFloatTest, Cross_Error_Vec4) { … }
TEST_F(ResolverBuiltinFloatTest, Cross_Error_TooManyParams) { … }
TEST_F(ResolverBuiltinFloatTest, Distance_Scalar_f32) { … }
TEST_F(ResolverBuiltinFloatTest, Distance_Scalar_f16) { … }
TEST_F(ResolverBuiltinFloatTest, Distance_Vector_f32) { … }
TEST_F(ResolverBuiltinFloatTest, Distance_Vector_f16) { … }
TEST_F(ResolverBuiltinFloatTest, Distance_TooManyParams) { … }
TEST_F(ResolverBuiltinFloatTest, Distance_TooFewParams) { … }
TEST_F(ResolverBuiltinFloatTest, Distance_NoParams) { … }
TEST_F(ResolverBuiltinFloatTest, FrexpScalar_f32) { … }
TEST_F(ResolverBuiltinFloatTest, FrexpScalar_f16) { … }
TEST_F(ResolverBuiltinFloatTest, FrexpVector_f32) { … }
TEST_F(ResolverBuiltinFloatTest, FrexpVector_f16) { … }
TEST_F(ResolverBuiltinFloatTest, Frexp_Error_FirstParamInt) { … }
TEST_F(ResolverBuiltinFloatTest, Length_Scalar_f32) { … }
TEST_F(ResolverBuiltinFloatTest, Length_Scalar_f16) { … }
TEST_F(ResolverBuiltinFloatTest, Length_FloatVector_f32) { … }
TEST_F(ResolverBuiltinFloatTest, Length_FloatVector_f16) { … }
TEST_F(ResolverBuiltinFloatTest, Length_NoParams) { … }
TEST_F(ResolverBuiltinFloatTest, Length_TooManyParams) { … }
TEST_F(ResolverBuiltinFloatTest, Mix_VectorScalar_f32) { … }
TEST_F(ResolverBuiltinFloatTest, Mix_VectorScalar_f16) { … }
TEST_F(ResolverBuiltinFloatTest, ModfScalar_f32) { … }
TEST_F(ResolverBuiltinFloatTest, ModfScalar_f16) { … }
TEST_F(ResolverBuiltinFloatTest, ModfVector_f32) { … }
TEST_F(ResolverBuiltinFloatTest, ModfVector_f16) { … }
TEST_F(ResolverBuiltinFloatTest, Modf_Error_FirstParamInt) { … }
TEST_F(ResolverBuiltinFloatTest, Modf_Error_SecondParamIntPtr) { … }
TEST_F(ResolverBuiltinFloatTest, Modf_Error_SecondParamNotAPointer) { … }
TEST_F(ResolverBuiltinFloatTest, Modf_Error_VectorSizesDontMatch) { … }
TEST_F(ResolverBuiltinFloatTest, Normalize_Vector_f32) { … }
TEST_F(ResolverBuiltinFloatTest, Normalize_Vector_f16) { … }
TEST_F(ResolverBuiltinFloatTest, Normalize_Error_NoParams) { … }
}
namespace integer_builtin_tests {
struct BuiltinDataWithParamNum { … };
inline std::ostream& operator<<(std::ostream& out, BuiltinDataWithParamNum data) { … }
ResolverBuiltinTest_IntegerBuiltin_IdenticalType;
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, Error_NoParams) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, OneParams_Scalar_i32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, OneParams_Vector_i32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, OneParams_Scalar_u32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, OneParams_Vector_u32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, TwoParams_Scalar_i32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, TwoParams_Vector_i32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, TwoParams_Scalar_u32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, TwoParams_Vector_u32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, ThreeParams_Scalar_i32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, ThreeParams_Vector_i32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, ThreeParams_Scalar_u32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, ThreeParams_Vector_u32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, FourParams_Scalar_i32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, FourParams_Vector_i32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, FourParams_Scalar_u32) { … }
TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, FourParams_Vector_u32) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
namespace matrix_builtin_tests {
TEST_F(ResolverBuiltinTest, Determinant_2x2_f32) { … }
TEST_F(ResolverBuiltinTest, Determinant_2x2_f16) { … }
TEST_F(ResolverBuiltinTest, Determinant_3x3_f32) { … }
TEST_F(ResolverBuiltinTest, Determinant_3x3_f16) { … }
TEST_F(ResolverBuiltinTest, Determinant_4x4_f32) { … }
TEST_F(ResolverBuiltinTest, Determinant_4x4_f16) { … }
TEST_F(ResolverBuiltinTest, Determinant_NotSquare) { … }
TEST_F(ResolverBuiltinTest, Determinant_NotMatrix) { … }
}
namespace vector_builtin_tests {
TEST_F(ResolverBuiltinTest, Dot_Vec2_f32) { … }
TEST_F(ResolverBuiltinTest, Dot_Vec2_f16) { … }
TEST_F(ResolverBuiltinTest, Dot_Vec3_i32) { … }
TEST_F(ResolverBuiltinTest, Dot_Vec4_u32) { … }
TEST_F(ResolverBuiltinTest, Dot_Error_Scalar) { … }
}
namespace derivative_builtin_tests {
ResolverBuiltinDerivativeTest;
TEST_P(ResolverBuiltinDerivativeTest, Scalar) { … }
TEST_P(ResolverBuiltinDerivativeTest, Vector) { … }
TEST_P(ResolverBuiltinDerivativeTest, MissingParam) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
namespace texture_builtin_tests {
enum class Texture { … };
template <typename STREAM, typename = traits::EnableIfIsOStream<STREAM>>
auto& operator<<(STREAM& out, Texture data) { … }
struct TextureTestParams { … };
inline std::ostream& operator<<(std::ostream& out, TextureTestParams data) { … }
class ResolverBuiltinTest_TextureOperation : public ResolverTestWithParam<TextureTestParams> { … };
ResolverBuiltinTest_SampledTextureOperation;
TEST_P(ResolverBuiltinTest_SampledTextureOperation, TextureLoadSampled) { … }
INSTANTIATE_TEST_SUITE_P(…);
ResolverBuiltinTest_Texture;
INSTANTIATE_TEST_SUITE_P(…);
static std::string to_str(const std::string& func, VectorRef<const sem::Parameter*> params) { … }
static const char* expected_texture_overload(ast::test::ValidTextureOverload overload) { … }
TEST_P(ResolverBuiltinTest_Texture, Call) { … }
}
namespace data_packing_builtin_tests {
ResolverBuiltinTest_DataPacking;
TEST_P(ResolverBuiltinTest_DataPacking, InferType) { … }
TEST_P(ResolverBuiltinTest_DataPacking, Error_IncorrectParamType) { … }
TEST_P(ResolverBuiltinTest_DataPacking, Error_NoParams) { … }
TEST_P(ResolverBuiltinTest_DataPacking, Error_TooManyParams) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
namespace data_unpacking_builtin_tests {
ResolverBuiltinTest_DataUnpacking;
TEST_P(ResolverBuiltinTest_DataUnpacking, InferType) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
namespace synchronization_builtin_tests {
ResolverBuiltinTest_Barrier;
TEST_P(ResolverBuiltinTest_Barrier, InferType) { … }
TEST_P(ResolverBuiltinTest_Barrier, Error_TooManyParams) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
}
}