diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-02-27 13:26:45 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-27 19:01:55 +0000 |
commit | af19769831f1c4c3b90c85aa9f8851cd8bbf86d5 (patch) | |
tree | 5dd063830d41aff45eefcb524c868ac210016467 /tests/SkSLErrorTest.cpp | |
parent | 578f064a60b63ddfb00831e9e59a47060bfcefe0 (diff) |
Re-land of skslc switch support
This reverts commit 7d975fc200bbbea991ec4c04c08f3a5ea7b847af.
BUG=skia:
Change-Id: I57521f7a291a35cfed58d623ea4f8da29582d2c5
Reviewed-on: https://skia-review.googlesource.com/8993
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'tests/SkSLErrorTest.cpp')
-rw-r--r-- | tests/SkSLErrorTest.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/SkSLErrorTest.cpp b/tests/SkSLErrorTest.cpp index 301281c28e..bde5e70795 100644 --- a/tests/SkSLErrorTest.cpp +++ b/tests/SkSLErrorTest.cpp @@ -337,6 +337,10 @@ DEF_TEST(SkSLUseWithoutInitialize, r) { test_failure(r, "void main() { bool x; if (true && (false || x)) return; }", "error: 1: 'x' has not been assigned\n1 error\n"); + test_failure(r, + "void main() { int x; switch (3) { case 0: x = 0; case 1: x = 1; }" + "sk_FragColor = vec4(x); }", + "error: 1: 'x' has not been assigned\n1 error\n"); } DEF_TEST(SkSLUnreachable, r) { @@ -366,13 +370,16 @@ DEF_TEST(SkSLNoReturn, r) { DEF_TEST(SkSLBreakOutsideLoop, r) { test_failure(r, "void foo() { while(true) {} if (true) break; }", - "error: 1: break statement must be inside a loop\n1 error\n"); + "error: 1: break statement must be inside a loop or switch\n1 error\n"); } DEF_TEST(SkSLContinueOutsideLoop, r) { test_failure(r, "void foo() { for(;;); continue; }", "error: 1: continue statement must be inside a loop\n1 error\n"); + test_failure(r, + "void foo() { switch (1) { default: continue; } }", + "error: 1: continue statement must be inside a loop\n1 error\n"); } DEF_TEST(SkSLStaticIfError, r) { @@ -430,4 +437,25 @@ DEF_TEST(SkSLUnsupportedGLSLIdentifiers, r) { "error: 1: unknown identifier 'gl_FragColor'\n1 error\n"); } +DEF_TEST(SkSLWrongSwitchTypes, r) { + test_failure(r, + "void main() { switch (vec2(1)) { case 1: break; } }", + "error: 1: expected 'int', but found 'vec2'\n1 error\n"); + test_failure(r, + "void main() { switch (1) { case vec2(1): break; } }", + "error: 1: expected 'int', but found 'vec2'\n1 error\n"); +} + +DEF_TEST(SkSLNonConstantCase, r) { + test_failure(r, + "void main() { int x = 1; switch (1) { case x: break; } }", + "error: 1: case value must be a constant\n1 error\n"); +} + +DEF_TEST(SkSLDuplicateCase, r) { + test_failure(r, + "void main() { switch (1) { case 0: case 1: case 0: break; } }", + "error: 1: duplicate case value\n1 error\n"); +} + #endif |