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

Unified Diff: tests/SkSLErrorTest.cpp

Issue 2405383003: added basic dataflow analysis to skslc (Closed)
Patch Set: I have no idea what I was thinking 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
« no previous file with comments | « 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..d9109483b250014a4f7cbe53d15bcfe72eee8877 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,57 @@ 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++; }",
+ "error: 1: 'x' has not been assigned\n1 error\n");
+ test_failure(r,
+ "void main() { int x[2][2]; int i; x[i][1] = 4; }",
+ "error: 1: 'i' has not been assigned\n1 error\n");
+ test_failure(r,
+ "int main() { int r; return r; }",
+ "error: 1: 'r' has not been assigned\n1 error\n");
+ test_failure(r,
+ "void main() { int x; int y = x; }",
+ "error: 1: 'x' has not been assigned\n1 error\n");
+ test_failure(r,
+ "void main() { bool x; if (true && (false || x)) return; }",
+ "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; }",
+ "error: 1: unreachable\n1 error\n");
+ test_failure(r,
+ "void main() { return; while (true); }",
+ "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");
+}
« no previous file with comments | « tests/PrimitiveProcessorTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698