wsgl parser: Fix tests that have multiple errors

A number of tests check the first encountered error is correct.
As the parser currently aborts after the first error, later errors are ignored.

Once the parser supports resynchronization, we'll emit multiple error messages, and these tests will start to fail. Fix them now.

Bug: tint:282
Change-Id: If8d0c41f030c652500b2e3b7284297b7a448d23e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32282
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2020-11-11 14:15:05 +00:00 committed by Commit Bot service account
parent 54af8746ae
commit b707258c8f
2 changed files with 15 additions and 15 deletions

View File

@ -238,9 +238,9 @@ TEST_F(ParserImplErrorTest, ForLoopMissingRParen) {
}
TEST_F(ParserImplErrorTest, ForLoopMissingLBrace) {
EXPECT("fn f() -> void { for (var i : i32 = 0; i < 8; i=i+1) } }",
EXPECT("fn f() -> void { for (var i : i32 = 0; i < 8; i=i+1) }",
"test.wgsl:1:54 error: expected '{' for for loop\n"
"fn f() -> void { for (var i : i32 = 0; i < 8; i=i+1) } }\n"
"fn f() -> void { for (var i : i32 = 0; i < 8; i=i+1) }\n"
" ^\n");
}
@ -715,31 +715,31 @@ TEST_F(ParserImplErrorTest, GlobalDeclStructMemberMissingSemicolon) {
}
TEST_F(ParserImplErrorTest, GlobalDeclStructMemberOffsetMissingLParen) {
EXPECT("struct S { [[offset 1)]] i : i32 };",
EXPECT("struct S { [[offset 1)]] i : i32; };",
"test.wgsl:1:21 error: expected '(' for offset decoration\n"
"struct S { [[offset 1)]] i : i32 };\n"
"struct S { [[offset 1)]] i : i32; };\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructMemberOffsetMissingRParen) {
EXPECT("struct S { [[offset(1]] i : i32 };",
EXPECT("struct S { [[offset(1]] i : i32; };",
"test.wgsl:1:22 error: expected ')' for offset decoration\n"
"struct S { [[offset(1]] i : i32 };\n"
"struct S { [[offset(1]] i : i32; };\n"
" ^^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructMemberOffsetInvaldValue) {
EXPECT("struct S { [[offset(x)]] i : i32 };",
EXPECT("struct S { [[offset(x)]] i : i32; };",
"test.wgsl:1:21 error: expected signed integer literal for offset "
"decoration\n"
"struct S { [[offset(x)]] i : i32 };\n"
"struct S { [[offset(x)]] i : i32; };\n"
" ^\n");
}
TEST_F(ParserImplErrorTest, GlobalDeclStructMemberOffsetNegativeValue) {
EXPECT("struct S { [[offset(-2)]] i : i32 };",
EXPECT("struct S { [[offset(-2)]] i : i32; };",
"test.wgsl:1:21 error: offset decoration must be positive\n"
"struct S { [[offset(-2)]] i : i32 };\n"
"struct S { [[offset(-2)]] i : i32; };\n"
" ^^\n");
}
@ -1127,9 +1127,9 @@ TEST_F(ParserImplErrorTest, LogicalOrInvalidExpr) {
}
TEST_F(ParserImplErrorTest, LoopMissingLBrace) {
EXPECT("fn f() -> void { loop } }",
EXPECT("fn f() -> void { loop }",
"test.wgsl:1:23 error: expected '{' for loop\n"
"fn f() -> void { loop } }\n"
"fn f() -> void { loop }\n"
" ^\n");
}
@ -1219,9 +1219,9 @@ TEST_F(ParserImplErrorTest, SwitchStmtCaseMissingColon) {
}
TEST_F(ParserImplErrorTest, SwitchStmtCaseMissingLBrace) {
EXPECT("fn f() -> void { switch(1) { case 1: } } }",
EXPECT("fn f() -> void { switch(1) { case 1: } }",
"test.wgsl:1:38 error: expected '{' for case statement\n"
"fn f() -> void { switch(1) { case 1: } } }\n"
"fn f() -> void { switch(1) { case 1: } }\n"
" ^\n");
}

View File

@ -39,7 +39,7 @@ TEST_F(ParserImplTest, FunctionHeader) {
}
TEST_F(ParserImplTest, FunctionHeader_MissingIdent) {
auto* p = parser("fn () ->");
auto* p = parser("fn () -> void");
auto f = p->function_header();
EXPECT_FALSE(f.matched);
EXPECT_TRUE(f.errored);