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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 test_failure(r, | 132 test_failure(r, |
133 "void main() { vec4 test = vec2(1).xxxxx; }", | 133 "void main() { vec4 test = vec2(1).xxxxx; }", |
134 "error: 1: too many components in swizzle mask 'xxxxx'\n1 error
\n"); | 134 "error: 1: too many components in swizzle mask 'xxxxx'\n1 error
\n"); |
135 } | 135 } |
136 | 136 |
137 DEF_TEST(SkSLSwizzleDuplicateOutput, r) { | 137 DEF_TEST(SkSLSwizzleDuplicateOutput, r) { |
138 test_failure(r, | 138 test_failure(r, |
139 "void main() { vec4 test = vec4(1); test.xyyz = vec4(1); }", | 139 "void main() { vec4 test = vec4(1); test.xyyz = vec4(1); }", |
140 "error: 1: cannot write to the same swizzle field more than onc
e\n1 error\n"); | 140 "error: 1: cannot write to the same swizzle field more than onc
e\n1 error\n"); |
141 } | 141 } |
| 142 |
142 DEF_TEST(SkSLAssignmentTypeMismatch, r) { | 143 DEF_TEST(SkSLAssignmentTypeMismatch, r) { |
143 test_failure(r, | 144 test_failure(r, |
144 "void main() { int x = 1.0; }", | 145 "void main() { int x = 1.0; }", |
145 "error: 1: expected 'int', but found 'float'\n1 error\n"); | 146 "error: 1: expected 'int', but found 'float'\n1 error\n"); |
| 147 test_failure(r, |
| 148 "void main() { int x; x = 1.0; }", |
| 149 "error: 1: type mismatch: '=' cannot operate on 'int', 'float'\
n1 error\n"); |
| 150 test_success(r, |
| 151 "void main() { vec3 x = vec3(0); x *= 1.0; }"); |
| 152 test_failure(r, |
| 153 "void main() { ivec3 x = ivec3(0); x *= 1.0; }", |
| 154 "error: 1: type mismatch: '*=' cannot operate on 'ivec3', 'floa
t'\n1 error\n"); |
146 } | 155 } |
147 | 156 |
148 DEF_TEST(SkSLReturnFromVoid, r) { | 157 DEF_TEST(SkSLReturnFromVoid, r) { |
149 test_failure(r, | 158 test_failure(r, |
150 "void main() { return true; }", | 159 "void main() { return true; }", |
151 "error: 1: may not return a value from a void function\n1 error
\n"); | 160 "error: 1: may not return a value from a void function\n1 error
\n"); |
152 } | 161 } |
153 | 162 |
154 DEF_TEST(SkSLReturnMissingValue, r) { | 163 DEF_TEST(SkSLReturnMissingValue, r) { |
155 test_failure(r, | 164 test_failure(r, |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 test_failure(r, | 334 test_failure(r, |
326 "void foo() { while(true) {} if (true) break; }", | 335 "void foo() { while(true) {} if (true) break; }", |
327 "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"); |
328 } | 337 } |
329 | 338 |
330 DEF_TEST(SkSLContinueOutsideLoop, r) { | 339 DEF_TEST(SkSLContinueOutsideLoop, r) { |
331 test_failure(r, | 340 test_failure(r, |
332 "void foo() { for(;;); continue; }", | 341 "void foo() { for(;;); continue; }", |
333 "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"
); |
334 } | 343 } |
OLD | NEW |