#include "src/tint/lang/core/builtin_value.h"
#include "src/tint/lang/core/type/texture_dimension.h"
#include "src/tint/lang/wgsl/ast/disable_validation_attribute.h"
#include "src/tint/lang/wgsl/ast/transform/add_block_attribute.h"
#include "src/tint/lang/wgsl/resolver/resolver.h"
#include "src/tint/lang/wgsl/resolver/resolver_helper_test.h"
#include "src/tint/utils/containers/transform.h"
#include "src/tint/utils/macros/compiler.h"
#include "src/tint/utils/text/string_stream.h"
#include "gmock/gmock.h"
namespace tint::resolver {
usingnamespacetint::core::fluent_types;
usingnamespacetint::core::number_suffixes;
DataType;
alias;
alias1;
alias2;
alias3;
namespace AttributeTests {
namespace {
enum class AttributeKind { … };
static std::ostream& operator<<(std::ostream& o, AttributeKind k) { … }
static bool IsBindingAttribute(AttributeKind kind) { … }
struct TestParams { … };
static constexpr const char* Pass = …;
static std::vector<TestParams> OnlyDiagnosticValidFor(std::string thing) { … }
static std::ostream& operator<<(std::ostream& o, const TestParams& c) { … }
const ast::Attribute* CreateAttribute(const Source& source,
ProgramBuilder& builder,
AttributeKind kind) { … }
struct TestWithParams : ResolverTestWithParam<TestParams> { … };
#undef CHECK
#define CHECK() …
namespace FunctionTests {
VoidFunctionAttributeTest;
TEST_P(VoidFunctionAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
NonVoidFunctionAttributeTest;
TEST_P(NonVoidFunctionAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
namespace FunctionInputAndOutputTests {
FunctionParameterAttributeTest;
TEST_P(FunctionParameterAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
FunctionReturnTypeAttributeTest;
TEST_P(FunctionReturnTypeAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
namespace EntryPointInputAndOutputTests {
ComputeShaderParameterAttributeTest;
TEST_P(ComputeShaderParameterAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
FragmentShaderParameterAttributeTest;
TEST_P(FragmentShaderParameterAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
VertexShaderParameterAttributeTest;
TEST_P(VertexShaderParameterAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
ComputeShaderReturnTypeAttributeTest;
TEST_P(ComputeShaderReturnTypeAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
FragmentShaderReturnTypeAttributeTest;
TEST_P(FragmentShaderReturnTypeAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
VertexShaderReturnTypeAttributeTest;
TEST_P(VertexShaderReturnTypeAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
EntryPointParameterAttributeTest;
TEST_F(EntryPointParameterAttributeTest, DuplicateInternalAttribute) { … }
EntryPointReturnTypeAttributeTest;
TEST_F(EntryPointReturnTypeAttributeTest, DuplicateInternalAttribute) { … }
}
namespace StructAndStructMemberTests {
StructAttributeTest;
SpirvBlockAttribute;
TEST_P(StructAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
StructMemberAttributeTest;
TEST_P(StructMemberAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(StructMemberAttributeTest, Align_Attribute_Const) { … }
TEST_F(StructMemberAttributeTest, Align_Attribute_ConstNegative) { … }
TEST_F(StructMemberAttributeTest, Align_Attribute_ConstPowerOfTwo) { … }
TEST_F(StructMemberAttributeTest, Align_Attribute_ConstF32) { … }
TEST_F(StructMemberAttributeTest, Align_Attribute_ConstU32) { … }
TEST_F(StructMemberAttributeTest, Align_Attribute_ConstAInt) { … }
TEST_F(StructMemberAttributeTest, Align_Attribute_ConstAFloat) { … }
TEST_F(StructMemberAttributeTest, Align_Attribute_Var) { … }
TEST_F(StructMemberAttributeTest, Align_Attribute_Override) { … }
TEST_F(StructMemberAttributeTest, Size_Attribute_Const) { … }
TEST_F(StructMemberAttributeTest, Size_Attribute_ConstNegative) { … }
TEST_F(StructMemberAttributeTest, Size_Attribute_ConstF32) { … }
TEST_F(StructMemberAttributeTest, Size_Attribute_ConstU32) { … }
TEST_F(StructMemberAttributeTest, Size_Attribute_ConstAInt) { … }
TEST_F(StructMemberAttributeTest, Size_Attribute_ConstAFloat) { … }
TEST_F(StructMemberAttributeTest, Size_Attribute_Var) { … }
TEST_F(StructMemberAttributeTest, Size_Attribute_Override) { … }
TEST_F(StructMemberAttributeTest, Size_On_RuntimeSizedArray) { … }
}
ArrayAttributeTest;
TEST_P(ArrayAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
VariableAttributeTest;
TEST_P(VariableAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(VariableAttributeTest, LocalVar) { … }
TEST_F(VariableAttributeTest, LocalLet) { … }
ConstantAttributeTest;
TEST_P(ConstantAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
OverrideAttributeTest;
TEST_P(OverrideAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
SwitchStatementAttributeTest;
TEST_P(SwitchStatementAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
SwitchBodyAttributeTest;
TEST_P(SwitchBodyAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
IfStatementAttributeTest;
TEST_P(IfStatementAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
ForStatementAttributeTest;
TEST_P(ForStatementAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
LoopStatementAttributeTest;
TEST_P(LoopStatementAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
WhileStatementAttributeTest;
TEST_P(WhileStatementAttributeTest, IsValid) { … }
INSTANTIATE_TEST_SUITE_P(…);
BlockStatementTest;
TEST_P(BlockStatementTest, CompoundStatement) { … }
TEST_P(BlockStatementTest, FunctionBody) { … }
TEST_P(BlockStatementTest, IfStatementBody) { … }
TEST_P(BlockStatementTest, ElseStatementBody) { … }
TEST_P(BlockStatementTest, ForStatementBody) { … }
TEST_P(BlockStatementTest, LoopStatementBody) { … }
TEST_P(BlockStatementTest, WhileStatementBody) { … }
TEST_P(BlockStatementTest, CaseStatementBody) { … }
TEST_P(BlockStatementTest, DefaultStatementBody) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
}
namespace ArrayStrideTests {
namespace {
struct Params { … };
template <typename T>
constexpr Params ParamsFor(uint32_t stride, bool should_pass) { … }
struct TestWithParams : ResolverTestWithParam<Params> { … };
ArrayStrideTest;
TEST_P(ArrayStrideTest, All) { … }
struct SizeAndAlignment { … };
constexpr SizeAndAlignment default_u32 = …;
constexpr SizeAndAlignment default_i32 = …;
constexpr SizeAndAlignment default_f32 = …;
constexpr SizeAndAlignment default_vec2 = …;
constexpr SizeAndAlignment default_vec3 = …;
constexpr SizeAndAlignment default_vec4 = …;
constexpr SizeAndAlignment default_mat2x2 = …;
constexpr SizeAndAlignment default_mat3x3 = …;
constexpr SizeAndAlignment default_mat4x4 = …;
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(ArrayStrideTest, DuplicateAttribute) { … }
}
}
namespace ResourceTests {
namespace {
ResourceAttributeTest;
TEST_F(ResourceAttributeTest, UniformBufferMissingBinding) { … }
TEST_F(ResourceAttributeTest, StorageBufferMissingBinding) { … }
TEST_F(ResourceAttributeTest, TextureMissingBinding) { … }
TEST_F(ResourceAttributeTest, SamplerMissingBinding) { … }
TEST_F(ResourceAttributeTest, BindingPairMissingBinding) { … }
TEST_F(ResourceAttributeTest, BindingPairMissingGroup) { … }
TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) { … }
TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) { … }
TEST_F(ResourceAttributeTest, BindingPointOnNonResource) { … }
}
}
namespace WorkgroupAttributeTests {
namespace {
WorkgroupAttribute;
TEST_F(WorkgroupAttribute, NotAnEntryPoint) { … }
TEST_F(WorkgroupAttribute, NotAComputeShader) { … }
TEST_F(WorkgroupAttribute, DuplicateAttribute) { … }
}
}
namespace InterpolateTests {
namespace {
InterpolateTest;
struct Params { … };
struct TestWithParams : ResolverTestWithParam<Params> { … };
InterpolateParameterTest;
TEST_P(InterpolateParameterTest, All) { … }
TEST_P(InterpolateParameterTest, IntegerScalar) { … }
TEST_P(InterpolateParameterTest, IntegerVector) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(InterpolateTest, FragmentInput_Integer_MissingFlatInterpolation) { … }
TEST_F(InterpolateTest, VertexOutput_Integer_MissingFlatInterpolation) { … }
GroupAndBindingTest;
TEST_F(GroupAndBindingTest, Const_I32) { … }
TEST_F(GroupAndBindingTest, Const_U32) { … }
TEST_F(GroupAndBindingTest, Const_AInt) { … }
TEST_F(GroupAndBindingTest, Binding_NonConstant) { … }
TEST_F(GroupAndBindingTest, Binding_Negative) { … }
TEST_F(GroupAndBindingTest, Binding_F32) { … }
TEST_F(GroupAndBindingTest, Binding_AFloat) { … }
TEST_F(GroupAndBindingTest, Group_NonConstant) { … }
TEST_F(GroupAndBindingTest, Group_Negative) { … }
TEST_F(GroupAndBindingTest, Group_F32) { … }
TEST_F(GroupAndBindingTest, Group_AFloat) { … }
IdTest;
TEST_F(IdTest, Const_I32) { … }
TEST_F(IdTest, Const_U32) { … }
TEST_F(IdTest, Const_AInt) { … }
TEST_F(IdTest, NonConstant) { … }
TEST_F(IdTest, Negative) { … }
TEST_F(IdTest, F32) { … }
TEST_F(IdTest, AFloat) { … }
enum class LocationAttributeType { … };
struct LocationTest : ResolverTestWithParam<LocationAttributeType> { … };
TEST_P(LocationTest, Const_I32) { … }
TEST_P(LocationTest, Const_U32) { … }
TEST_P(LocationTest, Const_AInt) { … }
TEST_P(LocationTest, NonConstant) { … }
TEST_P(LocationTest, Negative) { … }
TEST_P(LocationTest, F32) { … }
TEST_P(LocationTest, AFloat) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
}
namespace InternalAttributeDeps {
namespace {
class TestAttribute : public Castable<TestAttribute, ast::InternalAttribute> { … };
InternalAttributeDepsTest;
TEST_F(InternalAttributeDepsTest, Dependency) { … }
}
}
}
TINT_INSTANTIATE_TYPEINFO(…);