aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/SkSLErrorTest.cpp
diff options
context:
space:
mode:
authorGravatar ethannicholas <ethannicholas@google.com>2016-11-09 13:26:45 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-11-09 13:26:45 -0800
commit08a9211a8492a84e1f4a6899759f8f37ed5aec3e (patch)
tree8fe430d685b62467d0a59aa374ef7b98d6a3db4a /tests/SkSLErrorTest.cpp
parentf2b024db6777a904d986c68a21ba0bc41f956f6e (diff)
added constant folding & branch elimination to skslc
Diffstat (limited to 'tests/SkSLErrorTest.cpp')
-rw-r--r--tests/SkSLErrorTest.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/SkSLErrorTest.cpp b/tests/SkSLErrorTest.cpp
index 9e89b71473..fc20fa2e6d 100644
--- a/tests/SkSLErrorTest.cpp
+++ b/tests/SkSLErrorTest.cpp
@@ -352,3 +352,19 @@ DEF_TEST(SkSLContinueOutsideLoop, r) {
"void foo() { for(;;); continue; }",
"error: 1: continue statement must be inside a loop\n1 error\n");
}
+
+DEF_TEST(SkSLStaticIfError, r) {
+ // ensure eliminated branch of static if / ternary is still checked for errors
+ test_failure(r,
+ "void foo() { if (true); else x = 5; }",
+ "error: 1: unknown identifier 'x'\n1 error\n");
+ test_failure(r,
+ "void foo() { if (false) x = 5; }",
+ "error: 1: unknown identifier 'x'\n1 error\n");
+ test_failure(r,
+ "void foo() { true ? 5 : x; }",
+ "error: 1: unknown identifier 'x'\n1 error\n");
+ test_failure(r,
+ "void foo() { false ? x : 5; }",
+ "error: 1: unknown identifier 'x'\n1 error\n");
+}