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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « tests/PrimitiveProcessorTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkSLCompiler.h" 8 #include "SkSLCompiler.h"
9 9
10 #include "Test.h" 10 #include "Test.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 DEF_TEST(SkSLUsingInvalidValue, r) { 174 DEF_TEST(SkSLUsingInvalidValue, r) {
175 test_failure(r, 175 test_failure(r,
176 "void main() { int x = int; }", 176 "void main() { int x = int; }",
177 "error: 1: expected '(' to begin constructor invocation\n1 erro r\n"); 177 "error: 1: expected '(' to begin constructor invocation\n1 erro r\n");
178 test_failure(r, 178 test_failure(r,
179 "int test() { return 1; } void main() { int x = test; }", 179 "int test() { return 1; } void main() { int x = test; }",
180 "error: 1: expected '(' to begin function call\n1 error\n"); 180 "error: 1: expected '(' to begin function call\n1 error\n");
181 } 181 }
182 DEF_TEST(SkSLDifferentReturnType, r) { 182 DEF_TEST(SkSLDifferentReturnType, r) {
183 test_failure(r, 183 test_failure(r,
184 "int main() { } void main() { }", 184 "int main() { return 1; } void main() { }",
185 "error: 1: functions 'void main()' and 'int main()' differ only in return type\n1 " 185 "error: 1: functions 'void main()' and 'int main()' differ only in return type\n1 "
186 "error\n"); 186 "error\n");
187 } 187 }
188 188
189 DEF_TEST(SkSLDifferentModifiers, r) { 189 DEF_TEST(SkSLDifferentModifiers, r) {
190 test_failure(r, 190 test_failure(r,
191 "void test(int x); void test(out int x) { }", 191 "void test(int x); void test(out int x) { }",
192 "error: 1: modifiers on parameter 1 differ between declaration and definition\n1 " 192 "error: 1: modifiers on parameter 1 differ between declaration and definition\n1 "
193 "error\n"); 193 "error\n");
194 } 194 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 test_failure(r, 271 test_failure(r,
272 "void main() { int x = 5 > 2 ? true : 1.0; }", 272 "void main() { int x = 5 > 2 ? true : 1.0; }",
273 "error: 1: ternary operator result mismatch: 'bool', 'float'\n1 error\n"); 273 "error: 1: ternary operator result mismatch: 'bool', 'float'\n1 error\n");
274 } 274 }
275 275
276 DEF_TEST(SkSLInterfaceBlockStorageModifiers, r) { 276 DEF_TEST(SkSLInterfaceBlockStorageModifiers, r) {
277 test_failure(r, 277 test_failure(r,
278 "uniform foo { out int x; };", 278 "uniform foo { out int x; };",
279 "error: 1: interface block fields may not have storage qualifie rs\n1 error\n"); 279 "error: 1: interface block fields may not have storage qualifie rs\n1 error\n");
280 } 280 }
281
282 DEF_TEST(SkSLUseWithoutInitialize, r) {
283 test_failure(r,
284 "void main() { int x; if (5 == 2) x = 3; x++; }",
285 "error: 1: 'x' has not been assigned\n1 error\n");
286 test_failure(r,
287 "void main() { int x[2][2]; int i; x[i][1] = 4; }",
288 "error: 1: 'i' has not been assigned\n1 error\n");
289 test_failure(r,
290 "int main() { int r; return r; }",
291 "error: 1: 'r' has not been assigned\n1 error\n");
292 test_failure(r,
293 "void main() { int x; int y = x; }",
294 "error: 1: 'x' has not been assigned\n1 error\n");
295 test_failure(r,
296 "void main() { bool x; if (true && (false || x)) return; }",
297 "error: 1: 'x' has not been assigned\n1 error\n");
298 }
299
300 DEF_TEST(SkSLUnreachable, r) {
301 test_failure(r,
302 "void main() { return; return; }",
303 "error: 1: unreachable\n1 error\n");
304 test_failure(r,
305 "void main() { for (;;) { continue; int x = 1; } }",
306 "error: 1: unreachable\n1 error\n");
307 test_failure(r,
308 "void main() { for (;;) { } return; }",
309 "error: 1: unreachable\n1 error\n");
310 test_failure(r,
311 "void main() { if (true) return; else discard; return; }",
312 "error: 1: unreachable\n1 error\n");
313 test_failure(r,
314 "void main() { return; while (true); }",
315 "error: 1: unreachable\n1 error\n");
316 }
317
318 DEF_TEST(SkSLNoReturn, r) {
319 test_failure(r,
320 "int foo() { if (2 > 5) return 3; }",
321 "error: 1: function can exit without returning a value\n1 error \n");
322 }
323
324 DEF_TEST(SkSLBreakOutsideLoop, r) {
325 test_failure(r,
326 "void foo() { while(true) {} if (true) break; }",
327 "error: 1: break statement must be inside a loop\n1 error\n");
328 }
329
330 DEF_TEST(SkSLContinueOutsideLoop, r) {
331 test_failure(r,
332 "void foo() { for(;;); continue; }",
333 "error: 1: continue statement must be inside a loop\n1 error\n" );
334 }
OLDNEW
« 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