1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "src/sksl/SkSLCompiler.h"
9
10 #include "tests/Test.h"
11
test_failure(skiatest::Reporter * r,const char * src,const char * error)12 static void test_failure(skiatest::Reporter* r, const char* src, const char* error) {
13 SkSL::Compiler compiler;
14 SkSL::Program::Settings settings;
15 sk_sp<GrShaderCaps> caps = SkSL::ShaderCapsFactory::Default();
16 settings.fCaps = caps.get();
17 std::unique_ptr<SkSL::Program> program = compiler.convertProgram(SkSL::Program::kFragment_Kind,
18 SkSL::String(src), settings);
19 if (!compiler.errorCount()) {
20 compiler.optimize(*program);
21 }
22 SkSL::String skError(error);
23 if (compiler.errorText() != skError) {
24 SkDebugf("SKSL ERROR:\n source: %s\n expected: %s received: %s", src, error,
25 compiler.errorText().c_str());
26 }
27 REPORTER_ASSERT(r, compiler.errorText() == skError);
28 }
29
test_success(skiatest::Reporter * r,const char * src)30 static void test_success(skiatest::Reporter* r, const char* src) {
31 SkSL::Compiler compiler;
32 SkSL::Program::Settings settings;
33 sk_sp<GrShaderCaps> caps = SkSL::ShaderCapsFactory::Default();
34 settings.fCaps = caps.get();
35 std::unique_ptr<SkSL::Program> program = compiler.convertProgram(SkSL::Program::kFragment_Kind,
36 SkSL::String(src), settings);
37 REPORTER_ASSERT(r, program);
38 }
39
DEF_TEST(SkSLOpenArray,r)40 DEF_TEST(SkSLOpenArray, r) {
41 test_failure(r,
42 "void main(inout float4 color) { color.r[ = ( color.g ); }",
43 "error: 1: expected expression, but found '='\n1 error\n");
44 }
45
DEF_TEST(SkSLUndefinedSymbol,r)46 DEF_TEST(SkSLUndefinedSymbol, r) {
47 test_failure(r,
48 "void main() { x = float2(1); }",
49 "error: 1: unknown identifier 'x'\n1 error\n");
50 }
51
DEF_TEST(SkSLUndefinedFunction,r)52 DEF_TEST(SkSLUndefinedFunction, r) {
53 test_failure(r,
54 "void main() { int x = foo(1); }",
55 "error: 1: unknown identifier 'foo'\n1 error\n");
56 }
57
DEF_TEST(SkSLGenericArgumentMismatch,r)58 DEF_TEST(SkSLGenericArgumentMismatch, r) {
59 test_failure(r,
60 "void main() { float x = sin(1, 2); }",
61 "error: 1: no match for sin(int, int)\n1 error\n");
62 test_failure(r,
63 "void main() { float x = sin(true); }",
64 "error: 1: no match for sin(bool)\n1 error\n");
65 test_success(r,
66 "void main() { float x = sin(1); }");
67 }
68
DEF_TEST(SkSLArgumentCountMismatch,r)69 DEF_TEST(SkSLArgumentCountMismatch, r) {
70 test_failure(r,
71 "float foo(float x) { return x * x; }"
72 "void main() { float x = foo(1, 2); }",
73 "error: 1: call to 'foo' expected 1 argument, but found 2\n1 error\n");
74 }
75
DEF_TEST(SkSLArgumentMismatch,r)76 DEF_TEST(SkSLArgumentMismatch, r) {
77 test_failure(r,
78 "float foo(float x) { return x * x; }"
79 "void main() { float x = foo(true); }",
80 "error: 1: expected 'float', but found 'bool'\n1 error\n");
81 }
82
DEF_TEST(SkSLIfTypeMismatch,r)83 DEF_TEST(SkSLIfTypeMismatch, r) {
84 test_failure(r,
85 "void main() { if (3) { } }",
86 "error: 1: expected 'bool', but found 'int'\n1 error\n");
87 }
88
DEF_TEST(SkSLDoTypeMismatch,r)89 DEF_TEST(SkSLDoTypeMismatch, r) {
90 test_failure(r,
91 "void main() { do { } while (float2(1)); }",
92 "error: 1: expected 'bool', but found 'float2'\n1 error\n");
93 }
94
DEF_TEST(SkSLWhileTypeMismatch,r)95 DEF_TEST(SkSLWhileTypeMismatch, r) {
96 test_failure(r,
97 "void main() { while (float3(1)) { } }",
98 "error: 1: expected 'bool', but found 'float3'\n1 error\n");
99 }
100
DEF_TEST(SkSLForTypeMismatch,r)101 DEF_TEST(SkSLForTypeMismatch, r) {
102 test_failure(r,
103 "void main() { for (int x = 0; x; x++) { } }",
104 "error: 1: expected 'bool', but found 'int'\n1 error\n");
105 }
106
DEF_TEST(SkSLConstructorTypeMismatch,r)107 DEF_TEST(SkSLConstructorTypeMismatch, r) {
108 test_failure(r,
109 "void main() { float2 x = float2(1.0, false); }",
110 "error: 1: expected 'float', but found 'bool'\n1 error\n");
111 test_failure(r,
112 "void main() { float2 x = float2(bool2(false)); }",
113 "error: 1: 'bool2' is not a valid parameter to 'float2' constructor\n1 error\n");
114 test_failure(r,
115 "void main() { bool2 x = bool2(float2(1)); }",
116 "error: 1: 'float2' is not a valid parameter to 'bool2' constructor\n1 error\n");
117 test_failure(r,
118 "void main() { bool x = bool(1.0); }",
119 "error: 1: cannot construct 'bool'\n1 error\n");
120 test_failure(r,
121 "struct foo { int x; }; void main() { foo x = foo(5); }",
122 "error: 1: cannot construct 'foo'\n1 error\n");
123 test_failure(r,
124 "struct foo { int x; } foo; void main() { float x = float(foo); }",
125 "error: 1: invalid argument to 'float' constructor (expected a number or bool, but found 'foo')\n1 error\n");
126 test_failure(r,
127 "struct foo { int x; } foo; void main() { float2 x = float2(foo); }",
128 "error: 1: 'foo' is not a valid parameter to 'float2' constructor\n1 error\n");
129 test_failure(r,
130 "void main() { float2x2 x = float2x2(true); }",
131 "error: 1: expected 'float', but found 'bool'\n1 error\n");
132 }
133
DEF_TEST(SkSLConstructorArgumentCount,r)134 DEF_TEST(SkSLConstructorArgumentCount, r) {
135 test_failure(r,
136 "void main() { float3 x = float3(1.0, 2.0); }",
137 "error: 1: invalid arguments to 'float3' constructor (expected 3 scalars, but "
138 "found 2)\n1 error\n");
139 test_failure(r,
140 "void main() { float3 x = float3(1.0, 2.0, 3.0, 4.0); }",
141 "error: 1: invalid arguments to 'float3' constructor (expected 3 scalars, but found "
142 "4)\n1 error\n");
143 }
144
DEF_TEST(SkSLSwizzleScalar,r)145 DEF_TEST(SkSLSwizzleScalar, r) {
146 test_failure(r,
147 "void main() { float x = 1; float y = x.y; }",
148 "error: 1: cannot swizzle value of type 'float'\n1 error\n");
149 }
150
DEF_TEST(SkSLSwizzleMatrix,r)151 DEF_TEST(SkSLSwizzleMatrix, r) {
152 test_failure(r,
153 "void main() { float2x2 x = float2x2(1); float y = x.y; }",
154 "error: 1: cannot swizzle value of type 'float2x2'\n1 error\n");
155 }
156
DEF_TEST(SkSLSwizzleOutOfBounds,r)157 DEF_TEST(SkSLSwizzleOutOfBounds, r) {
158 test_failure(r,
159 "void main() { float3 test = float2(1).xyz; }",
160 "error: 1: invalid swizzle component 'z'\n1 error\n");
161 }
162
DEF_TEST(SkSLSwizzleTooManyComponents,r)163 DEF_TEST(SkSLSwizzleTooManyComponents, r) {
164 test_failure(r,
165 "void main() { float4 test = float2(1).xxxxx; }",
166 "error: 1: too many components in swizzle mask 'xxxxx'\n1 error\n");
167 }
168
DEF_TEST(SkSLSwizzleDuplicateOutput,r)169 DEF_TEST(SkSLSwizzleDuplicateOutput, r) {
170 test_failure(r,
171 "void main() { float4 test = float4(1); test.xyyz = float4(1); }",
172 "error: 1: cannot write to the same swizzle field more than once\n1 error\n");
173 }
174
DEF_TEST(SkSLSwizzleConstantOutput,r)175 DEF_TEST(SkSLSwizzleConstantOutput, r) {
176 test_failure(r,
177 "void main() { float4 test = float4(1); test.xyz0 = float4(1); }",
178 "error: 1: cannot write to a swizzle mask containing a constant\n1 error\n");
179 }
180
DEF_TEST(SkSLAssignmentTypeMismatch,r)181 DEF_TEST(SkSLAssignmentTypeMismatch, r) {
182 test_failure(r,
183 "void main() { int x = 1.0; }",
184 "error: 1: expected 'int', but found 'float'\n1 error\n");
185 test_failure(r,
186 "void main() { int x; x = 1.0; }",
187 "error: 1: type mismatch: '=' cannot operate on 'int', 'float'\n1 error\n");
188 test_success(r,
189 "void main() { float3 x = float3(0); x *= 1.0; }");
190 test_failure(r,
191 "void main() { int3 x = int3(0); x *= 1.0; }",
192 "error: 1: type mismatch: '*=' cannot operate on 'int3', 'float'\n1 error\n");
193 }
194
DEF_TEST(SkSLReturnFromVoid,r)195 DEF_TEST(SkSLReturnFromVoid, r) {
196 test_failure(r,
197 "void main() { return true; }",
198 "error: 1: may not return a value from a void function\n1 error\n");
199 }
200
DEF_TEST(SkSLReturnMissingValue,r)201 DEF_TEST(SkSLReturnMissingValue, r) {
202 test_failure(r,
203 "int foo() { return; } void main() { }",
204 "error: 1: expected function to return 'int'\n1 error\n");
205 }
206
DEF_TEST(SkSLReturnTypeMismatch,r)207 DEF_TEST(SkSLReturnTypeMismatch, r) {
208 test_failure(r,
209 "int foo() { return 1.0; } void main() { }",
210 "error: 1: expected 'int', but found 'float'\n1 error\n");
211 }
212
DEF_TEST(SkSLDuplicateFunction,r)213 DEF_TEST(SkSLDuplicateFunction, r) {
214 test_failure(r,
215 "void main() { } void main() { }",
216 "error: 1: duplicate definition of void main()\n1 error\n");
217 test_success(r,
218 "void main(); void main() { }");
219 }
220
DEF_TEST(SkSLUsingInvalidValue,r)221 DEF_TEST(SkSLUsingInvalidValue, r) {
222 test_failure(r,
223 "void main() { int x = int; }",
224 "error: 1: expected '(' to begin constructor invocation\n1 error\n");
225 test_failure(r,
226 "int test() { return 1; } void main() { int x = test; }",
227 "error: 1: expected '(' to begin function call\n1 error\n");
228 }
DEF_TEST(SkSLDifferentReturnType,r)229 DEF_TEST(SkSLDifferentReturnType, r) {
230 test_failure(r,
231 "int main() { return 1; } void main() { }",
232 "error: 1: functions 'void main()' and 'int main()' differ only in return type\n1 "
233 "error\n");
234 }
235
DEF_TEST(SkSLDifferentModifiers,r)236 DEF_TEST(SkSLDifferentModifiers, r) {
237 test_failure(r,
238 "void test(int x); void test(out int x) { }",
239 "error: 1: modifiers on parameter 1 differ between declaration and definition\n1 "
240 "error\n");
241 }
242
DEF_TEST(SkSLDuplicateSymbol,r)243 DEF_TEST(SkSLDuplicateSymbol, r) {
244 test_failure(r,
245 "int main; void main() { }",
246 "error: 1: symbol 'main' was already defined\n1 error\n");
247
248 test_failure(r,
249 "int x; int x; void main() { }",
250 "error: 1: symbol 'x' was already defined\n1 error\n");
251
252 test_success(r, "int x; void main() { int x; }");
253 }
254
DEF_TEST(SkSLBinaryTypeMismatch,r)255 DEF_TEST(SkSLBinaryTypeMismatch, r) {
256 test_failure(r,
257 "void main() { float x = 3 * true; }",
258 "error: 1: type mismatch: '*' cannot operate on 'int', 'bool'\n1 error\n");
259 test_failure(r,
260 "void main() { bool x = 1 || 2.0; }",
261 "error: 1: type mismatch: '||' cannot operate on 'int', 'float'\n1 error\n");
262 test_failure(r,
263 "void main() { bool x = float2(0) == 0; }",
264 "error: 1: type mismatch: '==' cannot operate on 'float2', 'int'\n1 error\n");
265 test_failure(r,
266 "void main() { bool x = float2(0) != 0; }",
267 "error: 1: type mismatch: '!=' cannot operate on 'float2', 'int'\n1 error\n");
268 }
269
DEF_TEST(SkSLCallNonFunction,r)270 DEF_TEST(SkSLCallNonFunction, r) {
271 test_failure(r,
272 "void main() { float x = 3; x(); }",
273 "error: 1: not a function\n1 error\n");
274 }
275
DEF_TEST(SkSLInvalidUnary,r)276 DEF_TEST(SkSLInvalidUnary, r) {
277 test_failure(r,
278 "void main() { float4x4 x = float4x4(1); ++x; }",
279 "error: 1: '++' cannot operate on 'float4x4'\n1 error\n");
280 test_failure(r,
281 "void main() { float3 x = float3(1); --x; }",
282 "error: 1: '--' cannot operate on 'float3'\n1 error\n");
283 test_failure(r,
284 "void main() { float4x4 x = float4x4(1); x++; }",
285 "error: 1: '++' cannot operate on 'float4x4'\n1 error\n");
286 test_failure(r,
287 "void main() { float3 x = float3(1); x--; }",
288 "error: 1: '--' cannot operate on 'float3'\n1 error\n");
289 test_failure(r,
290 "void main() { int x = !12; }",
291 "error: 1: '!' cannot operate on 'int'\n1 error\n");
292 test_failure(r,
293 "struct foo { } bar; void main() { foo x = +bar; }",
294 "error: 1: '+' cannot operate on 'foo'\n1 error\n");
295 test_failure(r,
296 "struct foo { } bar; void main() { foo x = -bar; }",
297 "error: 1: '-' cannot operate on 'foo'\n1 error\n");
298 test_success(r,
299 "void main() { float2 x = float2(1, 1); x = +x; x = -x; }");
300 }
301
DEF_TEST(SkSLInvalidAssignment,r)302 DEF_TEST(SkSLInvalidAssignment, r) {
303 test_failure(r,
304 "void main() { 1 = 2; }",
305 "error: 1: cannot assign to this expression\n1 error\n");
306 test_failure(r,
307 "uniform int x; void main() { x = 0; }",
308 "error: 1: cannot modify immutable variable 'x'\n1 error\n");
309 test_failure(r,
310 "const int x; void main() { x = 0; }",
311 "error: 1: cannot modify immutable variable 'x'\n1 error\n");
312 }
313
DEF_TEST(SkSLBadIndex,r)314 DEF_TEST(SkSLBadIndex, r) {
315 test_failure(r,
316 "void main() { int x = 2[0]; }",
317 "error: 1: expected array, but found 'int'\n1 error\n");
318 test_failure(r,
319 "void main() { float2 x = float2(0); int y = x[0][0]; }",
320 "error: 1: expected array, but found 'float'\n1 error\n");
321 }
322
DEF_TEST(SkSLTernaryMismatch,r)323 DEF_TEST(SkSLTernaryMismatch, r) {
324 test_failure(r,
325 "void main() { int x = 5 > 2 ? true : 1.0; }",
326 "error: 1: ternary operator result mismatch: 'bool', 'float'\n1 error\n");
327 test_failure(r,
328 "void main() { int x = 5 > 2 ? float3(1) : 1.0; }",
329 "error: 1: ternary operator result mismatch: 'float3', 'float'\n1 error\n");
330 }
331
DEF_TEST(SkSLInterfaceBlockStorageModifiers,r)332 DEF_TEST(SkSLInterfaceBlockStorageModifiers, r) {
333 test_failure(r,
334 "uniform foo { out int x; };",
335 "error: 1: interface block fields may not have storage qualifiers\n1 error\n");
336 }
337
DEF_TEST(SkSLUseWithoutInitialize,r)338 DEF_TEST(SkSLUseWithoutInitialize, r) {
339 test_failure(r,
340 "void main() { int x; if (5 == 2) x = 3; x++; }",
341 "error: 1: 'x' has not been assigned\n1 error\n");
342 test_failure(r,
343 "void main() { int x[2][2]; int i; x[i][1] = 4; }",
344 "error: 1: 'i' has not been assigned\n1 error\n");
345 test_failure(r,
346 "int main() { int r; return r; }",
347 "error: 1: 'r' has not been assigned\n1 error\n");
348 test_failure(r,
349 "void main() { int x; int y = x; }",
350 "error: 1: 'x' has not been assigned\n1 error\n");
351 test_failure(r,
352 "void main() { bool x; if (true && (false || x)) return; }",
353 "error: 1: 'x' has not been assigned\n1 error\n");
354 test_failure(r,
355 "void main() { int x; switch (3) { case 0: x = 0; case 1: x = 1; }"
356 "sk_FragColor = half4(x); }",
357 "error: 1: 'x' has not been assigned\n1 error\n");
358 }
359
DEF_TEST(SkSLUnreachable,r)360 DEF_TEST(SkSLUnreachable, r) {
361 test_failure(r,
362 "void main() { return; return; }",
363 "error: 1: unreachable\n1 error\n");
364 test_failure(r,
365 "void main() { for (;;) { continue; int x = 1; } }",
366 "error: 1: unreachable\n1 error\n");
367 /* test_failure(r,
368 "void main() { for (;;) { } return; }",
369 "error: 1: unreachable\n1 error\n");*/
370 test_failure(r,
371 "void main() { if (true) return; else discard; return; }",
372 "error: 1: unreachable\n1 error\n");
373 test_failure(r,
374 "void main() { return; while (true); }",
375 "error: 1: unreachable\n1 error\n");
376 }
377
DEF_TEST(SkSLNoReturn,r)378 DEF_TEST(SkSLNoReturn, r) {
379 test_failure(r,
380 "int foo() { if (2 > 5) return 3; }",
381 "error: 1: function 'foo' can exit without returning a value\n1 error\n");
382 }
383
DEF_TEST(SkSLBreakOutsideLoop,r)384 DEF_TEST(SkSLBreakOutsideLoop, r) {
385 test_failure(r,
386 "void foo() { while(true) {} if (true) break; }",
387 "error: 1: break statement must be inside a loop or switch\n1 error\n");
388 }
389
DEF_TEST(SkSLContinueOutsideLoop,r)390 DEF_TEST(SkSLContinueOutsideLoop, r) {
391 test_failure(r,
392 "void foo() { for(;;); continue; }",
393 "error: 1: continue statement must be inside a loop\n1 error\n");
394 test_failure(r,
395 "void foo() { switch (1) { default: continue; } }",
396 "error: 1: continue statement must be inside a loop\n1 error\n");
397 }
398
DEF_TEST(SkSLStaticIfError,r)399 DEF_TEST(SkSLStaticIfError, r) {
400 // ensure eliminated branch of static if / ternary is still checked for errors
401 test_failure(r,
402 "void foo() { if (true); else x = 5; }",
403 "error: 1: unknown identifier 'x'\n1 error\n");
404 test_failure(r,
405 "void foo() { if (false) x = 5; }",
406 "error: 1: unknown identifier 'x'\n1 error\n");
407 test_failure(r,
408 "void foo() { true ? 5 : x; }",
409 "error: 1: unknown identifier 'x'\n1 error\n");
410 test_failure(r,
411 "void foo() { false ? x : 5; }",
412 "error: 1: unknown identifier 'x'\n1 error\n");
413 }
414
DEF_TEST(SkSLBadCap,r)415 DEF_TEST(SkSLBadCap, r) {
416 test_failure(r,
417 "bool b = sk_Caps.bugFreeDriver;",
418 "error: 1: unknown capability flag 'bugFreeDriver'\n1 error\n");
419 }
420
DEF_TEST(SkSLDivByZero,r)421 DEF_TEST(SkSLDivByZero, r) {
422 test_failure(r,
423 "int x = 1 / 0;",
424 "error: 1: division by zero\n1 error\n");
425 test_failure(r,
426 "float x = 1 / 0;",
427 "error: 1: division by zero\n1 error\n");
428 test_failure(r,
429 "float x = 1.0 / 0.0;",
430 "error: 1: division by zero\n1 error\n");
431 test_failure(r,
432 "float x = -67.0 / (3.0 - 3);",
433 "error: 1: division by zero\n1 error\n");
434 }
435
DEF_TEST(SkSLUnsupportedGLSLIdentifiers,r)436 DEF_TEST(SkSLUnsupportedGLSLIdentifiers, r) {
437 test_failure(r,
438 "void main() { float x = gl_FragCoord.x; };",
439 "error: 1: unknown identifier 'gl_FragCoord'\n1 error\n");
440 test_failure(r,
441 "void main() { float r = gl_FragColor.r; };",
442 "error: 1: unknown identifier 'gl_FragColor'\n1 error\n");
443 }
444
DEF_TEST(SkSLWrongSwitchTypes,r)445 DEF_TEST(SkSLWrongSwitchTypes, r) {
446 test_failure(r,
447 "void main() { switch (float2(1)) { case 1: break; } }",
448 "error: 1: expected 'int', but found 'float2'\n1 error\n");
449 test_failure(r,
450 "void main() { switch (1) { case float2(1): break; } }",
451 "error: 1: expected 'int', but found 'float2'\n1 error\n");
452 }
453
DEF_TEST(SkSLNonConstantCase,r)454 DEF_TEST(SkSLNonConstantCase, r) {
455 test_failure(r,
456 "void main() { int x = 1; switch (1) { case x: break; } }",
457 "error: 1: case value must be a constant\n1 error\n");
458 }
459
DEF_TEST(SkSLDuplicateCase,r)460 DEF_TEST(SkSLDuplicateCase, r) {
461 test_failure(r,
462 "void main() { switch (1) { case 0: case 1: case 0: break; } }",
463 "error: 1: duplicate case value\n1 error\n");
464 }
465
DEF_TEST(SkSLFieldAfterRuntimeArray,r)466 DEF_TEST(SkSLFieldAfterRuntimeArray, r) {
467 test_failure(r,
468 "buffer broken { float x[]; float y; };",
469 "error: 1: only the last entry in an interface block may be a runtime-sized "
470 "array\n1 error\n");
471 }
472
DEF_TEST(SkSLStaticIf,r)473 DEF_TEST(SkSLStaticIf, r) {
474 test_success(r,
475 "void main() { float x = 5; float y = 10;"
476 "@if (x < y) { sk_FragColor = half4(1); } }");
477 test_failure(r,
478 "void main() { float x = sqrt(25); float y = 10;"
479 "@if (x < y) { sk_FragColor = half4(1); } }",
480 "error: 1: static if has non-static test\n1 error\n");
481 }
482
DEF_TEST(SkSLStaticSwitch,r)483 DEF_TEST(SkSLStaticSwitch, r) {
484 test_success(r,
485 "void main() {"
486 "int x = 1;"
487 "@switch (x) {"
488 "case 1: sk_FragColor = half4(1); break;"
489 "default: sk_FragColor = half4(0);"
490 "}"
491 "}");
492 test_failure(r,
493 "void main() {"
494 "int x = int(sqrt(1));"
495 "@switch (x) {"
496 "case 1: sk_FragColor = half4(1); break;"
497 "default: sk_FragColor = half4(0);"
498 "}"
499 "}",
500 "error: 1: static switch has non-static test\n1 error\n");
501 test_failure(r,
502 "void main() {"
503 "int x = 1;"
504 "@switch (x) {"
505 "case 1: sk_FragColor = half4(1); if (sqrt(0) < sqrt(1)) break;"
506 "default: sk_FragColor = half4(0);"
507 "}"
508 "}",
509 "error: 1: static switch contains non-static conditional break\n1 error\n");
510 }
511
DEF_TEST(SkSLInterfaceBlockScope,r)512 DEF_TEST(SkSLInterfaceBlockScope, r) {
513 test_failure(r,
514 "uniform testBlock {"
515 "float x;"
516 "} test[x];",
517 "error: 1: unknown identifier 'x'\n1 error\n");
518 }
519
DEF_TEST(SkSLDuplicateOutput,r)520 DEF_TEST(SkSLDuplicateOutput, r) {
521 test_failure(r,
522 "layout (location=0, index=0) out half4 duplicateOutput;",
523 "error: 1: out location=0, index=0 is reserved for sk_FragColor\n1 error\n");
524 }
525
DEF_TEST(SkSLSpuriousFloat,r)526 DEF_TEST(SkSLSpuriousFloat, r) {
527 test_failure(r,
528 "void main() { float x; x = 1.5 2.5; }",
529 "error: 1: expected ';', but found '2.5'\n1 error\n");
530 }
531