Validator: add const init with param test
Also test initializing a const from a function parameter. Bug: tint:642 Change-Id: Ic10a4e8b5a2f67f56bc3720cb59f8d306e175d66 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45520 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
4daddd1759
commit
d6fe74b01f
|
@ -246,5 +246,23 @@ TEST_F(ValidateFunctionTest, FunctionVarInitWithParam) {
|
||||||
EXPECT_TRUE(v.Validate()) << v.error();
|
EXPECT_TRUE(v.Validate()) << v.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ValidateFunctionTest, FunctionConstInitWithParam) {
|
||||||
|
// fn foo(bar : f32) -> void{
|
||||||
|
// const baz : f32 = bar;
|
||||||
|
// }
|
||||||
|
|
||||||
|
auto* bar = Var("bar", ty.f32(), ast::StorageClass::kFunction);
|
||||||
|
auto* baz = Const("baz", ty.f32(), Expr("bar"));
|
||||||
|
|
||||||
|
Func("foo", ast::VariableList{bar}, ty.void_(), ast::StatementList{Decl(baz)},
|
||||||
|
ast::DecorationList{
|
||||||
|
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||||
|
});
|
||||||
|
|
||||||
|
ValidatorImpl& v = Build();
|
||||||
|
|
||||||
|
EXPECT_TRUE(v.Validate()) << v.error();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
Loading…
Reference in New Issue