Add tests to show correct handling of mixed && and ||.
This CL adds tests to verify the new parser handles the mixing of && and || correctly. Bug: tint:1599 Change-Id: I1a73d041a00118ed649522ae07fc1489021c4b41 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106461 Kokoro: Kokoro <noreply+kokoro@google.com> Auto-Submit: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
1c94938726
commit
fdd2ff1145
|
@ -250,6 +250,25 @@ TEST_F(ParserImplTest, Expression_InvalidRelational) {
|
|||
EXPECT_EQ(p->error(), "1:6: unable to parse right side of <= expression");
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, Expression_Associativity) {
|
||||
auto p = parser("1 < 2 || 2 < 3");
|
||||
auto e = p->expression();
|
||||
EXPECT_TRUE(e.matched);
|
||||
EXPECT_FALSE(e.errored);
|
||||
EXPECT_FALSE(p->has_error()) << p->error();
|
||||
ASSERT_NE(e.value, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, Expression_InvalidAssociativity) {
|
||||
auto p = parser("1 < 2 && 2 < 3 || 3 < 4");
|
||||
auto e = p->expression();
|
||||
EXPECT_FALSE(e.matched);
|
||||
EXPECT_TRUE(e.errored);
|
||||
EXPECT_TRUE(p->has_error());
|
||||
EXPECT_EQ(e.value, nullptr);
|
||||
EXPECT_EQ(p->error(), R"(1:7: mixing '&&' and '||' requires parenthesis)");
|
||||
}
|
||||
|
||||
namespace mixing_binary_ops {
|
||||
|
||||
struct BinaryOperatorInfo {
|
||||
|
|
Loading…
Reference in New Issue