Resolver: Add test for continue after var decl

Bug: tint:17
Change-Id: Ibd51269d60447fa0d6408fbaf5b6d023a95073f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44050
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-03-10 23:15:09 +00:00 committed by Commit Bot service account
parent 7e17bfbfd9
commit f4c0d54423
1 changed files with 20 additions and 0 deletions

View File

@ -503,6 +503,26 @@ TEST_F(ResolverValidationTest,
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverTest, Stmt_Loop_ContinueInLoopBodyAfterDecl_UsageInContinuing) {
// loop {
// var z : i32;
// continue;
//
// continuing {
// z = 2;
// }
// }
auto error_loc = Source{Source::Location{12, 34}};
auto* body = Block(Decl(Var("z", ty.i32(), ast::StorageClass::kNone)),
create<ast::ContinueStatement>());
auto* continuing = Block(Assign(Expr(error_loc, "z"), Expr(2)));
auto* loop_stmt = Loop(body, continuing);
WrapInFunction(loop_stmt);
EXPECT_TRUE(r()->Resolve());
}
TEST_F(ResolverValidationTest, Stmt_ContinueInLoop) {
WrapInFunction(Loop(Block(create<ast::ContinueStatement>(Source{{12, 34}}))));
EXPECT_TRUE(r()->Resolve()) << r()->error();