OLD | NEW |
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 25 matching lines...) Expand all Loading... |
36 | 36 |
37 DEF_TEST(SkSLUndefinedFunction, r) { | 37 DEF_TEST(SkSLUndefinedFunction, r) { |
38 test_failure(r, | 38 test_failure(r, |
39 "void main() { int x = foo(1); }", | 39 "void main() { int x = foo(1); }", |
40 "error: 1: unknown identifier 'foo'\n1 error\n"); | 40 "error: 1: unknown identifier 'foo'\n1 error\n"); |
41 } | 41 } |
42 | 42 |
43 DEF_TEST(SkSLGenericArgumentMismatch, r) { | 43 DEF_TEST(SkSLGenericArgumentMismatch, r) { |
44 test_failure(r, | 44 test_failure(r, |
45 "void main() { float x = sin(1, 2); }", | 45 "void main() { float x = sin(1, 2); }", |
46 "error: 1: call to 'sin' expected 1 argument, but found 2\n1 er
ror\n"); | 46 "error: 1: no match for sin(int, int)\n1 error\n"); |
47 test_failure(r, | |
48 "void main() { float x = sin(true); }", | |
49 "error: 1: no match for sin(bool)\n1 error\n"); | |
50 test_success(r, | |
51 "void main() { float x = sin(1); }"); | |
52 } | 47 } |
53 | 48 |
54 DEF_TEST(SkSLArgumentCountMismatch, r) { | 49 DEF_TEST(SkSLArgumentCountMismatch, r) { |
55 test_failure(r, | 50 test_failure(r, |
56 "float foo(float x) { return x * x; }" | 51 "float foo(float x) { return x * x; }" |
57 "void main() { float x = foo(1, 2); }", | 52 "void main() { float x = foo(1, 2); }", |
58 "error: 1: call to 'foo' expected 1 argument, but found 2\n1 er
ror\n"); | 53 "error: 1: call to 'foo' expected 1 argument, but found 2\n1 er
ror\n"); |
59 } | 54 } |
60 | 55 |
61 DEF_TEST(SkSLArgumentMismatch, r) { | 56 DEF_TEST(SkSLArgumentMismatch, r) { |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 test_failure(r, | 334 test_failure(r, |
340 "void foo() { while(true) {} if (true) break; }", | 335 "void foo() { while(true) {} if (true) break; }", |
341 "error: 1: break statement must be inside a loop\n1 error\n"); | 336 "error: 1: break statement must be inside a loop\n1 error\n"); |
342 } | 337 } |
343 | 338 |
344 DEF_TEST(SkSLContinueOutsideLoop, r) { | 339 DEF_TEST(SkSLContinueOutsideLoop, r) { |
345 test_failure(r, | 340 test_failure(r, |
346 "void foo() { for(;;); continue; }", | 341 "void foo() { for(;;); continue; }", |
347 "error: 1: continue statement must be inside a loop\n1 error\n"
); | 342 "error: 1: continue statement must be inside a loop\n1 error\n"
); |
348 } | 343 } |
OLD | NEW |