Index: tests/SkSLErrorTest.cpp |
diff --git a/tests/SkSLErrorTest.cpp b/tests/SkSLErrorTest.cpp |
index 9e89b71473ab5f3c56aa0238240b2781e232e724..fc20fa2e6d03a79e60f16be096f7716bba90ef09 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"); |
+} |