tint/resolver: Rename var_let_*test.cc -> variable_*test.cc

Gives us a place to put `const` and `override` tests.

Bug: tint:1580
Change-Id: I0340c37e96f796d2f879d4045623b35927e45c78
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94601
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2022-06-24 21:26:39 +00:00 committed by Dawn LUCI CQ
parent dfeaf29055
commit 68ae36e43d
4 changed files with 50 additions and 50 deletions

View File

@ -1118,8 +1118,8 @@ if (tint_build_unittests) {
"resolver/uniformity_test.cc",
"resolver/validation_test.cc",
"resolver/validator_is_storeable_test.cc",
"resolver/var_let_test.cc",
"resolver/var_let_validation_test.cc",
"resolver/variable_test.cc",
"resolver/variable_validation_test.cc",
]
deps = [ ":tint_unittests_ast_src" ]
}

View File

@ -814,8 +814,8 @@ if(TINT_BUILD_TESTS)
resolver/type_validation_test.cc
resolver/validation_test.cc
resolver/validator_is_storeable_test.cc
resolver/var_let_test.cc
resolver/var_let_validation_test.cc
resolver/variable_test.cc
resolver/variable_validation_test.cc
scope_stack_test.cc
sem/atomic.cc
sem/bool_test.cc

View File

@ -23,9 +23,9 @@ using namespace tint::number_suffixes; // NOLINT
namespace tint::resolver {
namespace {
struct ResolverVarLetTest : public resolver::TestHelper, public testing::Test {};
struct ResolverVariableTest : public resolver::TestHelper, public testing::Test {};
TEST_F(ResolverVarLetTest, VarDeclWithoutConstructor) {
TEST_F(ResolverVariableTest, VarDeclWithoutConstructor) {
// struct S { i : i32; }
// alias A = S;
// fn F(){
@ -82,7 +82,7 @@ TEST_F(ResolverVarLetTest, VarDeclWithoutConstructor) {
EXPECT_EQ(Sem().Get(a)->Constructor(), nullptr);
}
TEST_F(ResolverVarLetTest, VarDeclWithConstructor) {
TEST_F(ResolverVariableTest, VarDeclWithConstructor) {
// struct S { i : i32; }
// alias A = S;
// fn F(){
@ -146,7 +146,7 @@ TEST_F(ResolverVarLetTest, VarDeclWithConstructor) {
EXPECT_EQ(Sem().Get(a)->Constructor()->Declaration(), a_c);
}
TEST_F(ResolverVarLetTest, LetDecl) {
TEST_F(ResolverVariableTest, LetDecl) {
// struct S { i : i32; }
// fn F(){
// var v : i32;
@ -212,7 +212,7 @@ TEST_F(ResolverVarLetTest, LetDecl) {
EXPECT_EQ(Sem().Get(p)->Constructor()->Declaration(), p_c);
}
TEST_F(ResolverVarLetTest, DefaultVarStorageClass) {
TEST_F(ResolverVariableTest, DefaultVarStorageClass) {
// https://gpuweb.github.io/gpuweb/wgsl/#storage-class
auto* buf = Structure("S", {Member("m", ty.i32())});
@ -254,7 +254,7 @@ TEST_F(ResolverVarLetTest, DefaultVarStorageClass) {
EXPECT_EQ(TypeOf(handle)->As<sem::Reference>()->Access(), ast::Access::kRead);
}
TEST_F(ResolverVarLetTest, ExplicitVarStorageClass) {
TEST_F(ResolverVariableTest, ExplicitVarStorageClass) {
// https://gpuweb.github.io/gpuweb/wgsl/#storage-class
auto* buf = Structure("S", {Member("m", ty.i32())});
@ -271,7 +271,7 @@ TEST_F(ResolverVarLetTest, ExplicitVarStorageClass) {
EXPECT_EQ(TypeOf(storage)->As<sem::Reference>()->Access(), ast::Access::kReadWrite);
}
TEST_F(ResolverVarLetTest, LetInheritsAccessFromOriginatingVariable) {
TEST_F(ResolverVariableTest, LetInheritsAccessFromOriginatingVariable) {
// struct Inner {
// arr: array<i32, 4>;
// }
@ -304,7 +304,7 @@ TEST_F(ResolverVarLetTest, LetInheritsAccessFromOriginatingVariable) {
EXPECT_EQ(TypeOf(ptr)->As<sem::Pointer>()->Access(), ast::Access::kReadWrite);
}
TEST_F(ResolverVarLetTest, LocalShadowsAlias) {
TEST_F(ResolverVariableTest, LocalShadowsAlias) {
// type a = i32;
//
// fn X() {
@ -334,7 +334,7 @@ TEST_F(ResolverVarLetTest, LocalShadowsAlias) {
EXPECT_EQ(local_l->Shadows(), type_t);
}
TEST_F(ResolverVarLetTest, LocalShadowsStruct) {
TEST_F(ResolverVariableTest, LocalShadowsStruct) {
// struct a {
// m : i32;
// };
@ -366,7 +366,7 @@ TEST_F(ResolverVarLetTest, LocalShadowsStruct) {
EXPECT_EQ(local_l->Shadows(), type_t);
}
TEST_F(ResolverVarLetTest, LocalShadowsFunction) {
TEST_F(ResolverVariableTest, LocalShadowsFunction) {
// fn a() {
// var a = true;
// }
@ -396,7 +396,7 @@ TEST_F(ResolverVarLetTest, LocalShadowsFunction) {
EXPECT_EQ(local_l->Shadows(), func_b);
}
TEST_F(ResolverVarLetTest, LocalShadowsGlobalVar) {
TEST_F(ResolverVariableTest, LocalShadowsGlobalVar) {
// var<private> a : i32;
//
// fn X() {
@ -435,7 +435,7 @@ TEST_F(ResolverVarLetTest, LocalShadowsGlobalVar) {
EXPECT_EQ(user_l->Variable(), global);
}
TEST_F(ResolverVarLetTest, LocalShadowsGlobalLet) {
TEST_F(ResolverVariableTest, LocalShadowsGlobalLet) {
// let a : i32 = 1;
//
// fn X() {
@ -474,7 +474,7 @@ TEST_F(ResolverVarLetTest, LocalShadowsGlobalLet) {
EXPECT_EQ(user_l->Variable(), global);
}
TEST_F(ResolverVarLetTest, LocalShadowsLocalVar) {
TEST_F(ResolverVariableTest, LocalShadowsLocalVar) {
// fn X() {
// var a : i32;
// {
@ -513,7 +513,7 @@ TEST_F(ResolverVarLetTest, LocalShadowsLocalVar) {
EXPECT_EQ(user_l->Variable(), local_s);
}
TEST_F(ResolverVarLetTest, LocalShadowsLocalLet) {
TEST_F(ResolverVariableTest, LocalShadowsLocalLet) {
// fn X() {
// let a = 1;
// {
@ -552,7 +552,7 @@ TEST_F(ResolverVarLetTest, LocalShadowsLocalLet) {
EXPECT_EQ(user_l->Variable(), local_s);
}
TEST_F(ResolverVarLetTest, LocalShadowsParam) {
TEST_F(ResolverVariableTest, LocalShadowsParam) {
// fn F(a : i32) {
// {
// var a = a;
@ -590,7 +590,7 @@ TEST_F(ResolverVarLetTest, LocalShadowsParam) {
EXPECT_EQ(user_l->Variable(), param);
}
TEST_F(ResolverVarLetTest, ParamShadowsFunction) {
TEST_F(ResolverVariableTest, ParamShadowsFunction) {
// fn a(a : bool) {
// }
@ -608,7 +608,7 @@ TEST_F(ResolverVarLetTest, ParamShadowsFunction) {
EXPECT_EQ(param->Shadows(), func);
}
TEST_F(ResolverVarLetTest, ParamShadowsGlobalVar) {
TEST_F(ResolverVariableTest, ParamShadowsGlobalVar) {
// var<private> a : i32;
//
// fn F(a : bool) {
@ -629,7 +629,7 @@ TEST_F(ResolverVarLetTest, ParamShadowsGlobalVar) {
EXPECT_EQ(param->Shadows(), global);
}
TEST_F(ResolverVarLetTest, ParamShadowsGlobalLet) {
TEST_F(ResolverVariableTest, ParamShadowsGlobalLet) {
// let a : i32 = 1;
//
// fn F(a : bool) {
@ -650,7 +650,7 @@ TEST_F(ResolverVarLetTest, ParamShadowsGlobalLet) {
EXPECT_EQ(param->Shadows(), global);
}
TEST_F(ResolverVarLetTest, ParamShadowsAlias) {
TEST_F(ResolverVariableTest, ParamShadowsAlias) {
// type a = i32;
//
// fn F(a : a) {

View File

@ -22,9 +22,9 @@ using namespace tint::number_suffixes; // NOLINT
namespace tint::resolver {
namespace {
struct ResolverVarLetValidationTest : public resolver::TestHelper, public testing::Test {};
struct ResolverVariableValidationTest : public resolver::TestHelper, public testing::Test {};
TEST_F(ResolverVarLetValidationTest, VarNoInitializerNoType) {
TEST_F(ResolverVariableValidationTest, VarNoInitializerNoType) {
// var a;
WrapInFunction(Var(Source{{12, 34}}, "a", nullptr));
@ -32,7 +32,7 @@ TEST_F(ResolverVarLetValidationTest, VarNoInitializerNoType) {
EXPECT_EQ(r()->error(), "12:34 error: 'var' declaration requires a type or initializer");
}
TEST_F(ResolverVarLetValidationTest, GlobalVarNoInitializerNoType) {
TEST_F(ResolverVariableValidationTest, GlobalVarNoInitializerNoType) {
// var a;
Global(Source{{12, 34}}, "a", nullptr);
@ -40,7 +40,7 @@ TEST_F(ResolverVarLetValidationTest, GlobalVarNoInitializerNoType) {
EXPECT_EQ(r()->error(), "12:34 error: 'var' declaration requires a type or initializer");
}
TEST_F(ResolverVarLetValidationTest, OverrideNoInitializerNoType) {
TEST_F(ResolverVariableValidationTest, OverrideNoInitializerNoType) {
// override a;
Override(Source{{12, 34}}, "a", nullptr, nullptr);
@ -48,7 +48,7 @@ TEST_F(ResolverVarLetValidationTest, OverrideNoInitializerNoType) {
EXPECT_EQ(r()->error(), "12:34 error: 'override' declaration requires a type or initializer");
}
TEST_F(ResolverVarLetValidationTest, VarTypeNotStorable) {
TEST_F(ResolverVariableValidationTest, VarTypeNotStorable) {
// var i : i32;
// var p : pointer<function, i32> = &v;
auto* i = Var("i", ty.i32(), ast::StorageClass::kNone);
@ -62,7 +62,7 @@ TEST_F(ResolverVarLetValidationTest, VarTypeNotStorable) {
"type of a var");
}
TEST_F(ResolverVarLetValidationTest, LetTypeNotConstructible) {
TEST_F(ResolverVariableValidationTest, LetTypeNotConstructible) {
// @group(0) @binding(0) var t1 : texture_2d<f32>;
// let t2 : t1;
auto* t1 = Global("t1", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
@ -74,7 +74,7 @@ TEST_F(ResolverVarLetValidationTest, LetTypeNotConstructible) {
EXPECT_EQ(r()->error(), "56:78 error: texture_2d<f32> cannot be used as the type of a 'let'");
}
TEST_F(ResolverVarLetValidationTest, OverrideExplicitTypeNotScalar) {
TEST_F(ResolverVariableValidationTest, OverrideExplicitTypeNotScalar) {
// override o : vec3<f32>;
Override(Source{{56, 78}}, "o", ty.vec3<f32>(), nullptr);
@ -82,7 +82,7 @@ TEST_F(ResolverVarLetValidationTest, OverrideExplicitTypeNotScalar) {
EXPECT_EQ(r()->error(), "56:78 error: vec3<f32> cannot be used as the type of a 'override'");
}
TEST_F(ResolverVarLetValidationTest, OverrideInferedTypeNotScalar) {
TEST_F(ResolverVariableValidationTest, OverrideInferedTypeNotScalar) {
// override o = vec3(1.0f);
Override(Source{{56, 78}}, "o", nullptr, vec3<f32>(1.0_f));
@ -90,7 +90,7 @@ TEST_F(ResolverVarLetValidationTest, OverrideInferedTypeNotScalar) {
EXPECT_EQ(r()->error(), "56:78 error: vec3<f32> cannot be used as the type of a 'override'");
}
TEST_F(ResolverVarLetValidationTest, LetConstructorWrongType) {
TEST_F(ResolverVariableValidationTest, LetConstructorWrongType) {
// var v : i32 = 2u
WrapInFunction(Let(Source{{3, 3}}, "v", ty.i32(), Expr(2_u)));
@ -99,7 +99,7 @@ TEST_F(ResolverVarLetValidationTest, LetConstructorWrongType) {
R"(3:3 error: cannot initialize let of type 'i32' with value of type 'u32')");
}
TEST_F(ResolverVarLetValidationTest, VarConstructorWrongType) {
TEST_F(ResolverVariableValidationTest, VarConstructorWrongType) {
// var v : i32 = 2u
WrapInFunction(Var(Source{{3, 3}}, "v", ty.i32(), ast::StorageClass::kNone, Expr(2_u)));
@ -108,7 +108,7 @@ TEST_F(ResolverVarLetValidationTest, VarConstructorWrongType) {
R"(3:3 error: cannot initialize var of type 'i32' with value of type 'u32')");
}
TEST_F(ResolverVarLetValidationTest, LetConstructorWrongTypeViaAlias) {
TEST_F(ResolverVariableValidationTest, LetConstructorWrongTypeViaAlias) {
auto* a = Alias("I32", ty.i32());
WrapInFunction(Let(Source{{3, 3}}, "v", ty.Of(a), Expr(2_u)));
@ -117,7 +117,7 @@ TEST_F(ResolverVarLetValidationTest, LetConstructorWrongTypeViaAlias) {
R"(3:3 error: cannot initialize let of type 'i32' with value of type 'u32')");
}
TEST_F(ResolverVarLetValidationTest, VarConstructorWrongTypeViaAlias) {
TEST_F(ResolverVariableValidationTest, VarConstructorWrongTypeViaAlias) {
auto* a = Alias("I32", ty.i32());
WrapInFunction(Var(Source{{3, 3}}, "v", ty.Of(a), ast::StorageClass::kNone, Expr(2_u)));
@ -126,7 +126,7 @@ TEST_F(ResolverVarLetValidationTest, VarConstructorWrongTypeViaAlias) {
R"(3:3 error: cannot initialize var of type 'i32' with value of type 'u32')");
}
TEST_F(ResolverVarLetValidationTest, LetOfPtrConstructedWithRef) {
TEST_F(ResolverVariableValidationTest, LetOfPtrConstructedWithRef) {
// var a : f32;
// let b : ptr<function,f32> = a;
const auto priv = ast::StorageClass::kFunction;
@ -141,7 +141,7 @@ TEST_F(ResolverVarLetValidationTest, LetOfPtrConstructedWithRef) {
R"(12:34 error: cannot initialize let of type 'ptr<function, f32, read_write>' with value of type 'f32')");
}
TEST_F(ResolverVarLetValidationTest, LocalLetRedeclared) {
TEST_F(ResolverVariableValidationTest, LocalLetRedeclared) {
// let l : f32 = 1.;
// let l : i32 = 0;
auto* l1 = Let("l", ty.f32(), Expr(1_f));
@ -153,7 +153,7 @@ TEST_F(ResolverVarLetValidationTest, LocalLetRedeclared) {
"12:34 error: redeclaration of 'l'\nnote: 'l' previously declared here");
}
TEST_F(ResolverVarLetValidationTest, GlobalVarRedeclaredAsLocal) {
TEST_F(ResolverVariableValidationTest, GlobalVarRedeclaredAsLocal) {
// var v : f32 = 2.1;
// fn my_func() {
// var v : f32 = 2.0;
@ -167,7 +167,7 @@ TEST_F(ResolverVarLetValidationTest, GlobalVarRedeclaredAsLocal) {
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverVarLetValidationTest, VarRedeclaredInInnerBlock) {
TEST_F(ResolverVariableValidationTest, VarRedeclaredInInnerBlock) {
// {
// var v : f32;
// { var v : f32; }
@ -182,7 +182,7 @@ TEST_F(ResolverVarLetValidationTest, VarRedeclaredInInnerBlock) {
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverVarLetValidationTest, VarRedeclaredInIfBlock) {
TEST_F(ResolverVariableValidationTest, VarRedeclaredInIfBlock) {
// {
// var v : f32 = 3.14;
// if (true) { var v : f32 = 2.0; }
@ -201,7 +201,7 @@ TEST_F(ResolverVarLetValidationTest, VarRedeclaredInIfBlock) {
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverVarLetValidationTest, InferredPtrStorageAccessMismatch) {
TEST_F(ResolverVariableValidationTest, InferredPtrStorageAccessMismatch) {
// struct Inner {
// arr: array<i32, 4>;
// }
@ -234,7 +234,7 @@ TEST_F(ResolverVarLetValidationTest, InferredPtrStorageAccessMismatch) {
"'ptr<storage, i32, read>'");
}
TEST_F(ResolverVarLetValidationTest, NonConstructibleType_Atomic) {
TEST_F(ResolverVariableValidationTest, NonConstructibleType_Atomic) {
auto* v = Var("v", ty.atomic(Source{{12, 34}}, ty.i32()));
WrapInFunction(v);
@ -242,7 +242,7 @@ TEST_F(ResolverVarLetValidationTest, NonConstructibleType_Atomic) {
EXPECT_EQ(r()->error(), "12:34 error: function-scope 'var' must have a constructible type");
}
TEST_F(ResolverVarLetValidationTest, NonConstructibleType_RuntimeArray) {
TEST_F(ResolverVariableValidationTest, NonConstructibleType_RuntimeArray) {
auto* s = Structure("S", {Member(Source{{56, 78}}, "m", ty.array(ty.i32()))});
auto* v = Var(Source{{12, 34}}, "v", ty.Of(s));
WrapInFunction(v);
@ -254,7 +254,7 @@ TEST_F(ResolverVarLetValidationTest, NonConstructibleType_RuntimeArray) {
12:34 note: while instantiating 'var' v)");
}
TEST_F(ResolverVarLetValidationTest, NonConstructibleType_Struct_WithAtomic) {
TEST_F(ResolverVariableValidationTest, NonConstructibleType_Struct_WithAtomic) {
auto* s = Structure("S", {Member("m", ty.atomic(ty.i32()))});
auto* v = Var("v", ty.Of(s));
WrapInFunction(v);
@ -263,7 +263,7 @@ TEST_F(ResolverVarLetValidationTest, NonConstructibleType_Struct_WithAtomic) {
EXPECT_EQ(r()->error(), "error: function-scope 'var' must have a constructible type");
}
TEST_F(ResolverVarLetValidationTest, NonConstructibleType_InferredType) {
TEST_F(ResolverVariableValidationTest, NonConstructibleType_InferredType) {
// @group(0) @binding(0) var s : sampler;
// fn foo() {
// var v = s;
@ -276,7 +276,7 @@ TEST_F(ResolverVarLetValidationTest, NonConstructibleType_InferredType) {
EXPECT_EQ(r()->error(), "12:34 error: function-scope 'var' must have a constructible type");
}
TEST_F(ResolverVarLetValidationTest, InvalidStorageClassForInitializer) {
TEST_F(ResolverVariableValidationTest, InvalidStorageClassForInitializer) {
// var<workgroup> v : f32 = 1.23;
Global(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kWorkgroup, Expr(1.23_f));
@ -287,7 +287,7 @@ TEST_F(ResolverVarLetValidationTest, InvalidStorageClassForInitializer) {
"storage classes 'private' and 'function'");
}
TEST_F(ResolverVarLetValidationTest, VectorLetNoType) {
TEST_F(ResolverVariableValidationTest, VectorLetNoType) {
// let a : mat3x3 = mat3x3<f32>();
WrapInFunction(Let("a", create<ast::Vector>(Source{{12, 34}}, nullptr, 3), vec3<f32>()));
@ -295,7 +295,7 @@ TEST_F(ResolverVarLetValidationTest, VectorLetNoType) {
EXPECT_EQ(r()->error(), "12:34 error: missing vector element type");
}
TEST_F(ResolverVarLetValidationTest, VectorVarNoType) {
TEST_F(ResolverVariableValidationTest, VectorVarNoType) {
// var a : mat3x3;
WrapInFunction(Var("a", create<ast::Vector>(Source{{12, 34}}, nullptr, 3)));
@ -303,7 +303,7 @@ TEST_F(ResolverVarLetValidationTest, VectorVarNoType) {
EXPECT_EQ(r()->error(), "12:34 error: missing vector element type");
}
TEST_F(ResolverVarLetValidationTest, MatrixLetNoType) {
TEST_F(ResolverVariableValidationTest, MatrixLetNoType) {
// let a : mat3x3 = mat3x3<f32>();
WrapInFunction(Let("a", create<ast::Matrix>(Source{{12, 34}}, nullptr, 3, 3), mat3x3<f32>()));
@ -311,7 +311,7 @@ TEST_F(ResolverVarLetValidationTest, MatrixLetNoType) {
EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type");
}
TEST_F(ResolverVarLetValidationTest, MatrixVarNoType) {
TEST_F(ResolverVariableValidationTest, MatrixVarNoType) {
// var a : mat3x3;
WrapInFunction(Var("a", create<ast::Matrix>(Source{{12, 34}}, nullptr, 3, 3)));