Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: tests/SkSLErrorTest.cpp

Issue 2405383003: added basic dataflow analysis to skslc (Closed)
Patch Set: various fixes Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/sksl/SkSLIRGenerator.cpp ('K') | « tests/PrimitiveProcessorTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SkSLErrorTest.cpp
diff --git a/tests/SkSLErrorTest.cpp b/tests/SkSLErrorTest.cpp
index 400ab6dc57d343e16619eb0127b33581c21efc68..5ec73c595b70a4ee213ddf1906802702e22f702a 100644
--- a/tests/SkSLErrorTest.cpp
+++ b/tests/SkSLErrorTest.cpp
@@ -181,7 +181,7 @@ DEF_TEST(SkSLUsingInvalidValue, r) {
}
DEF_TEST(SkSLDifferentReturnType, r) {
test_failure(r,
- "int main() { } void main() { }",
+ "int main() { return 1; } void main() { }",
"error: 1: functions 'void main()' and 'int main()' differ only in return type\n1 "
"error\n");
}
@@ -278,3 +278,42 @@ DEF_TEST(SkSLInterfaceBlockStorageModifiers, r) {
"uniform foo { out int x; };",
"error: 1: interface block fields may not have storage qualifiers\n1 error\n");
}
+
+DEF_TEST(SkSLUseWithoutInitialize, r) {
+ test_failure(r,
+ "void main() { int x; if (5 == 2) x = 3; x++; }",
dogben 2016/10/13 03:55:43 Would be good to add a few more test cases: 1. ex
ethannicholas 2016/10/13 17:41:28 Done.
+ "error: 1: 'x' has not been assigned\n1 error\n");
+}
+
+DEF_TEST(SkSLUnreachable, r) {
+ test_failure(r,
+ "void main() { return; return; }",
+ "error: 1: unreachable\n1 error\n");
+ test_failure(r,
+ "void main() { for (;;) { continue; int x = 1; } }",
+ "error: 1: unreachable\n1 error\n");
+ test_failure(r,
+ "void main() { for (;;) { } return; }",
+ "error: 1: unreachable\n1 error\n");
+ test_failure(r,
+ "void main() { if (true) return; else discard; return; }",
dogben 2016/10/13 03:55:43 Maybe add this test case: (I think this works corr
ethannicholas 2016/10/13 17:41:28 Done.
+ "error: 1: unreachable\n1 error\n");
+}
+
+DEF_TEST(SkSLNoReturn, r) {
+ test_failure(r,
+ "int foo() { if (2 > 5) return 3; }",
+ "error: 1: function can exit without returning a value\n1 error\n");
+}
+
+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");
+}
+
+DEF_TEST(SkSLContinueOutsideLoop, r) {
+ test_failure(r,
+ "void foo() { for(;;); continue; }",
+ "error: 1: continue statement must be inside a loop\n1 error\n");
+}
« src/sksl/SkSLIRGenerator.cpp ('K') | « tests/PrimitiveProcessorTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698