validation: add test for function params behave as const decl

Bug: tint:257
Change-Id: Ia5cdde240ecd2fa17dfeb08872037c18004fce06
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54821
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
This commit is contained in:
Sarah 2021-06-18 14:53:13 +00:00 committed by Sarah Mashayekhi
parent 567f2e4f3b
commit c5cd6b9eb0
1 changed files with 8 additions and 0 deletions

View File

@ -331,6 +331,14 @@ TEST_F(ResolverFunctionValidationTest, FunctionConstInitWithParam) {
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverFunctionValidationTest, FunctionParamsConst) {
Func("foo", {Param(Sym("arg"), ty.i32())}, ty.void_(),
{Assign(Expr(Source{{12, 34}}, "arg"), Expr(1)), Return()});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: cannot assign to value of type 'i32'");
}
TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Literal_BadType) {
// [[stage(compute), workgroup_size(64.0)]
// fn main() {}