aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/SkSLGLSLTest.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-02-22 17:20:11 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-23 15:30:37 +0000
commit2b1e468dabd2ac7bea7ec17740275f4f4aad30c3 (patch)
tree6cd847e75b45c9f02f2c3f299ca81664434c0f85 /tests/SkSLGLSLTest.cpp
parent69d4992e69d7b142450d0ccb587b7b26be7cf1ea (diff)
skslc switch support
BUG=skia: Change-Id: Ida7f9e80139aa1e4f43804cafbcac640e47fab25 Reviewed-on: https://skia-review.googlesource.com/8771 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Ben Wagner <benjaminwagner@google.com>
Diffstat (limited to 'tests/SkSLGLSLTest.cpp')
-rw-r--r--tests/SkSLGLSLTest.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp
index a0fdb98dcf..53e5c6badf 100644
--- a/tests/SkSLGLSLTest.cpp
+++ b/tests/SkSLGLSLTest.cpp
@@ -777,4 +777,91 @@ DEF_TEST(SkSLGeometry, r) {
SkSL::Program::kGeometry_Kind);
}
+DEF_TEST(SkSLSwitch, r) {
+ test(r,
+ "void main() {"
+ " float x;"
+ " switch (1) {"
+ " case 0:"
+ " x = 0.0;"
+ " break;"
+ " case 1:"
+ " x = 1.0;"
+ " break;"
+ " default:"
+ " x = 2.0;"
+ " }"
+ " sk_FragColor = vec4(x);"
+ "}",
+ *SkSL::ShaderCapsFactory::Default(),
+ "#version 400\n"
+ "out vec4 sk_FragColor;\n"
+ "void main() {\n"
+ " float x;\n"
+ " switch (1) {\n"
+ " case 0:\n"
+ " x = 0.0;\n"
+ " break;\n"
+ " case 1:\n"
+ " x = 1.0;\n"
+ " break;\n"
+ " default:\n"
+ " x = 2.0;\n"
+ " }\n"
+ " sk_FragColor = vec4(x);\n"
+ "}\n");
+ test(r,
+ "void main() {"
+ " float x;"
+ " switch (2) {"
+ " case 0:"
+ " x = 0.0;"
+ " case 1:"
+ " x = 1.0;"
+ " default:"
+ " x = 2.0;"
+ " }"
+ " sk_FragColor = vec4(x);"
+ "}",
+ *SkSL::ShaderCapsFactory::Default(),
+ "#version 400\n"
+ "out vec4 sk_FragColor;\n"
+ "void main() {\n"
+ " float x;\n"
+ " switch (2) {\n"
+ " case 0:\n"
+ " x = 0.0;\n"
+ " case 1:\n"
+ " x = 1.0;\n"
+ " default:\n"
+ " x = 2.0;\n"
+ " }\n"
+ " sk_FragColor = vec4(2.0);\n"
+ "}\n");
+ test(r,
+ "void main() {"
+ " float x = 0.0;"
+ " switch (3) {"
+ " case 0:"
+ " x = 0.0;"
+ " case 1:"
+ " x = 1.0;"
+ " }"
+ " sk_FragColor = vec4(x);"
+ "}",
+ *SkSL::ShaderCapsFactory::Default(),
+ "#version 400\n"
+ "out vec4 sk_FragColor;\n"
+ "void main() {\n"
+ " float x = 0.0;\n"
+ " switch (3) {\n"
+ " case 0:\n"
+ " x = 0.0;\n"
+ " case 1:\n"
+ " x = 1.0;\n"
+ " }\n"
+ " sk_FragColor = vec4(x);\n"
+ "}\n");
+}
+
#endif