• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Tests todo:
2# - inout with varyings, attributes, uniforms (and arrays of 'em)
3# - inout with arrays, array elements
4# - inout with array elements
5# - inout by-value semantics (arrays & elements & structs)
6
7# Done:
8# - control flow: return, return in loop, etc.
9
10group datatypes "Function Parameter Data Types"
11
12	case float_float
13		version 300 es
14		values
15		{
16			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
17			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
18		}
19
20		both ""
21			#version 300 es
22			precision mediump float;
23			${DECLARATIONS}
24
25			float func (float a)
26			{
27				return -a;
28			}
29
30			void main()
31			{
32				out0 = func(in0);
33				${OUTPUT}
34			}
35		""
36	end
37
38	case float_vec2
39		version 300 es
40		values
41		{
42			input vec2 in0		= [ vec2(0.0, 1.0) | vec2(2.0, 2.5) ];
43			output float out0	= [ -1.0 | -4.5 ];
44		}
45
46		both ""
47			#version 300 es
48			precision mediump float;
49			${DECLARATIONS}
50
51			float func (vec2 a)
52			{
53				return -(a.x + a.y);
54			}
55
56			void main()
57			{
58				out0 = func(in0);
59				${OUTPUT}
60			}
61		""
62	end
63
64	case float_vec3
65		version 300 es
66		values
67		{
68			input vec3 in0		= [ vec3(0.0, 1.0, -2.0) | vec3(2.0, 2.5, -4.0) ];
69			output float out0	= [ 1.0 | -0.5 ];
70		}
71
72		both ""
73			#version 300 es
74			precision mediump float;
75			${DECLARATIONS}
76
77			float func (vec3 a)
78			{
79				return -(a.x + a.y + a.z);
80			}
81
82			void main()
83			{
84				out0 = func(in0);
85				${OUTPUT}
86			}
87		""
88	end
89
90	case float_vec4
91		version 300 es
92		values
93		{
94			input vec4 in0		= [ vec4(0.0, 1.0, -2.0, 0.5) | vec4(2.0, 2.5, 4.0, -7.0) ];
95			output float out0	= [ 0.5 | -1.5 ];
96		}
97
98		both ""
99			#version 300 es
100			precision mediump float;
101			${DECLARATIONS}
102
103			float func (vec4 a)
104			{
105				return -(a.x + a.y + a.z + a.w);
106			}
107
108			void main()
109			{
110				out0 = func(in0);
111				${OUTPUT}
112			}
113		""
114	end
115
116	case float_mat2
117		version 300 es
118		values
119		{
120			input mat2 in0		= [ mat2(0.0, 1.0, -2.0, 0.5) | mat2(2.0, 2.5, 4.0, -7.0) ];
121			output float out0	= [ 0.5 | -1.5 ];
122		}
123
124		both ""
125			#version 300 es
126			precision mediump float;
127			${DECLARATIONS}
128
129			float func (mat2 a)
130			{
131				return -(a[0][0] + a[0][1] + a[1][0] + a[1][1]);
132			}
133
134			void main()
135			{
136				out0 = func(in0);
137				${OUTPUT}
138			}
139		""
140	end
141
142	case float_mat3
143		version 300 es
144		values
145		{
146			input mat3 in0		= [ mat3(0.0, 1.0, -2.0, 0.5, 1.0, -1.0, 2.0, 4.0, -1.0) | mat3(2.0, 2.5, 4.0, -7.0, 2.5, 3.0, 0.5, -3.5, 1.0) ];
147			output float out0	= [ -4.5 | -5.0 ];
148		}
149
150		both ""
151			#version 300 es
152			precision mediump float;
153			${DECLARATIONS}
154
155			float func (mat3 a)
156			{
157				return -(a[0][0] + a[0][1] + a[0][2] + a[1][0] + a[1][1] + a[1][2] + a[2][0] + a[2][1] + a[2][2]);
158			}
159
160			void main()
161			{
162				out0 = func(in0);
163				${OUTPUT}
164			}
165		""
166	end
167
168	case float_mat4
169		version 300 es
170		values
171		{
172			input mat4 in0		= [ mat4(0.0, 1.0, -2.0, 0.5, 1.0, -1.0, 2.0, 4.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -2.0, -2.0) | mat4(2.0, 2.5, 4.0, -7.0, 2.5, 3.0, 0.5, -3.5, 1.0, 0.0, 2.0, -1.0, 1.0, 0.0, -1.0, 3.0) ];
173			output float out0	= [ -5.5 | -9.0 ];
174		}
175
176		both ""
177			#version 300 es
178			precision mediump float;
179			${DECLARATIONS}
180
181			float func (mat4 a)
182			{
183				return -(a[0][0] + a[0][1] + a[0][2] + a[0][3] + a[1][0] + a[1][1] + a[1][2] + a[1][3] + a[2][0] + a[2][1] + a[2][2] + a[2][3] + a[3][0] + a[3][1] + a[3][2] + a[3][3]);
184			}
185
186			void main()
187			{
188				out0 = func(in0);
189				${OUTPUT}
190			}
191		""
192	end
193
194	case int_int
195		version 300 es
196		values
197		{
198			input int in0		= [ -1 | 0 | 1 | 4 ];
199			output int out0		= [ 1 | 0 | -1 | -4 ];
200		}
201
202		both ""
203			#version 300 es
204			precision mediump float;
205			precision mediump int;
206			${DECLARATIONS}
207
208			int func (int a)
209			{
210				return -a;
211			}
212
213			void main()
214			{
215				${SETUP}
216				out0 = func(in0);
217				${OUTPUT}
218			}
219		""
220	end
221
222	case int_ivec2
223		version 300 es
224		values
225		{
226			input ivec2 in0		= [ ivec2(-1, 0) | ivec2(1, 4) ];
227			output int out0		= [ 1 | -5 ];
228		}
229
230		both ""
231			#version 300 es
232			precision mediump float;
233			precision mediump int;
234			${DECLARATIONS}
235
236			int func (ivec2 a)
237			{
238				return -(a.x + a.y);
239			}
240
241			void main()
242			{
243				${SETUP}
244				out0 = func(in0);
245				${OUTPUT}
246			}
247		""
248	end
249
250	case int_ivec3
251		version 300 es
252		values
253		{
254			input ivec3 in0		= [ ivec3(-1, 0, 2) | ivec3(1, 4, -8) ];
255			output int out0		= [ -1 | 3 ];
256		}
257
258		both ""
259			#version 300 es
260			precision mediump float;
261			precision mediump int;
262			${DECLARATIONS}
263
264			int func (ivec3 a)
265			{
266				return -(a.x + a.y + a.z);
267			}
268
269			void main()
270			{
271				${SETUP}
272				out0 = func(in0);
273				${OUTPUT}
274			}
275		""
276	end
277
278	case int_ivec4
279		version 300 es
280		values
281		{
282			input ivec4 in0		= [ ivec4(-1, 0, 2, 2) | ivec4(1, 4, -8, 2) ];
283			output int out0		= [ -3 | 1 ];
284		}
285
286		both ""
287			#version 300 es
288			precision mediump float;
289			precision mediump int;
290			${DECLARATIONS}
291
292			int func (ivec4 a)
293			{
294				return -(a.x + a.y + a.z + a.w);
295			}
296
297			void main()
298			{
299				${SETUP}
300				out0 = func(in0);
301				${OUTPUT}
302			}
303		""
304	end
305
306	case uint_uint
307		version 300 es
308		values
309		{
310			input uint in0		= [ 1 | 0 | 2 | 4 ];
311			output uint out0	= [ 1 | 0 | 4 | 16 ];
312		}
313
314		both ""
315			#version 300 es
316			precision mediump float;
317			precision mediump int;
318			${DECLARATIONS}
319
320			uint func (uint a)
321			{
322				return a*a;
323			}
324
325			void main()
326			{
327				${SETUP}
328				out0 = func(in0);
329				${OUTPUT}
330			}
331		""
332	end
333
334	case uint_uvec2
335		version 300 es
336		values
337		{
338			input uvec2 in0		= [ uvec2(1, 0) | uvec2(2, 4) ];
339			output uint out0	= [ 1 | 6 ];
340		}
341
342		both ""
343			#version 300 es
344			precision mediump float;
345			precision mediump int;
346			${DECLARATIONS}
347
348			uint func (uvec2 a)
349			{
350				return (a.x + a.y);
351			}
352
353			void main()
354			{
355				${SETUP}
356				out0 = func(in0);
357				${OUTPUT}
358			}
359		""
360	end
361
362	case uint_uvec3
363		version 300 es
364		values
365		{
366			input uvec3 in0		= [ uvec3(1, 0, 2) | uvec3(1, 4, 8) ];
367			output uint out0		= [ 3 | 13 ];
368		}
369
370		both ""
371			#version 300 es
372			precision mediump float;
373			precision mediump int;
374			${DECLARATIONS}
375
376			uint func (uvec3 a)
377			{
378				return (a.x + a.y + a.z);
379			}
380
381			void main()
382			{
383				${SETUP}
384				out0 = func(in0);
385				${OUTPUT}
386			}
387		""
388	end
389
390	case uint_uvec4
391		version 300 es
392		values
393		{
394			input uvec4 in0		= [ uvec4(1, 0, 2, 2) | uvec4(1, 4, 8, 2) ];
395			output uint out0	= [ 5 | 15 ];
396		}
397
398		both ""
399			#version 300 es
400			precision mediump float;
401			precision mediump int;
402			${DECLARATIONS}
403
404			uint func (uvec4 a)
405			{
406				return (a.x + a.y + a.z + a.w);
407			}
408
409			void main()
410			{
411				${SETUP}
412				out0 = func(in0);
413				${OUTPUT}
414			}
415		""
416	end
417
418	case bool_bool
419		version 300 es
420		values
421		{
422			input bool in0		= [ true | false ];
423			output bool out0	= [ false | true ];
424		}
425
426		both ""
427			#version 300 es
428			precision mediump float;
429			${DECLARATIONS}
430
431			bool func (bool a)
432			{
433				return !a;
434			}
435
436			void main()
437			{
438				${SETUP}
439				out0 = func(in0);
440				${OUTPUT}
441			}
442		""
443	end
444
445	case bool_bvec2
446		version 300 es
447		values
448		{
449			input bvec2 in0		= [ bvec2(true, true) | bvec2(false, true) ];
450			output bool out0	= [ false | true ];
451		}
452
453		both ""
454			#version 300 es
455			precision mediump float;
456			${DECLARATIONS}
457
458			bool func (bvec2 a)
459			{
460				return !(a.x == a.y);
461			}
462
463			void main()
464			{
465				${SETUP}
466				out0 = func(in0);
467				${OUTPUT}
468			}
469		""
470	end
471
472	case bool_bvec3
473		version 300 es
474		values
475		{
476			input bvec3 in0		= [ bvec3(true, true, false) | bvec3(true, false, false) ];
477			output bool out0	= [ false | true ];
478		}
479
480		both ""
481			#version 300 es
482			precision mediump float;
483			${DECLARATIONS}
484
485			bool func (bvec3 a)
486			{
487				return (a.x == a.y) == a.z;
488			}
489
490			void main()
491			{
492				${SETUP}
493				out0 = func(in0);
494				${OUTPUT}
495			}
496		""
497	end
498
499	case bool_bvec4
500		version 300 es
501		values
502		{
503			input bvec4 in0		= [ bvec4(true, true, true, false) | bvec4(false, false, true, true) | bvec4(true, false, false, true) ];
504			output bool out0	= [ false | true | true ];
505		}
506
507		both ""
508			#version 300 es
509			precision mediump float;
510			${DECLARATIONS}
511
512			bool func (bvec4 a)
513			{
514				return ((a.x == a.y) == (a.z == a.w));
515			}
516
517			void main()
518			{
519				${SETUP}
520				out0 = func(in0);
521				${OUTPUT}
522			}
523		""
524	end
525
526	case mat2
527		version 300 es
528		values
529		{
530			input mat2 in0	= [ mat2(-2.0, 0.5, -1.0, 1.0) | mat2(1.0, -3.5, -3.5, 2.5) | mat2(-2.0, -2.0, 3.5, 0.0) ];
531			output mat2 out0	= [ mat2(4.0, -1.0, 2.0, -2.0) | mat2(-2.0, 7.0, 7.0, -5.0) | mat2(4.0, 4.0, -7.0, -0.0) ];
532		}
533
534		both ""
535			#version 300 es
536			precision mediump float;
537			${DECLARATIONS}
538
539			mat2 func (mat2 a)
540			{
541				return -2.0*a;
542			}
543
544			void main()
545			{
546				${SETUP}
547				out0 = func(in0);
548				${OUTPUT}
549			}
550		""
551	end
552
553
554	case mat2x3
555		version 300 es
556		values
557		{
558			input mat2x3 in0	= [ mat2x3(2.5, 0.0, 1.0, -2.5, 1.0, 3.0) | mat2x3(0.0, 2.0, 1.5, -3.5, 2.0, 0.5) | mat2x3(-1.5, -3.5, 2.5, 0.0, 1.5, 3.0) ];
559			output mat2x3 out0	= [ mat2x3(-5.0, -0.0, -2.0, 5.0, -2.0, -6.0) | mat2x3(-0.0, -4.0, -3.0, 7.0, -4.0, -1.0) | mat2x3(3.0, 7.0, -5.0, -0.0, -3.0, -6.0) ];
560		}
561
562		both ""
563			#version 300 es
564			precision mediump float;
565			${DECLARATIONS}
566
567			mat2x3 func (mat2x3 a)
568			{
569				return -2.0*a;
570			}
571
572			void main()
573			{
574				${SETUP}
575				out0 = func(in0);
576				${OUTPUT}
577			}
578		""
579	end
580
581
582	case mat2x4
583		version 300 es
584		values
585		{
586			input mat2x4 in0	= [ mat2x4(1.5, 3.0, -1.0, 2.5, -0.5, 3.5, 3.0, -3.0) | mat2x4(-2.5, -2.0, 3.5, -0.5, 1.0, -1.5, 0.0, -1.0) | mat2x4(-1.0, 0.5, 0.5, 3.0, 1.5, 3.0, 2.5, 3.5) ];
587			output mat2x4 out0	= [ mat2x4(-3.0, -6.0, 2.0, -5.0, 1.0, -7.0, -6.0, 6.0) | mat2x4(5.0, 4.0, -7.0, 1.0, -2.0, 3.0, -0.0, 2.0) | mat2x4(2.0, -1.0, -1.0, -6.0, -3.0, -6.0, -5.0, -7.0) ];
588		}
589
590		both ""
591			#version 300 es
592			precision mediump float;
593			${DECLARATIONS}
594
595			mat2x4 func (mat2x4 a)
596			{
597				return -2.0*a;
598			}
599
600			void main()
601			{
602				${SETUP}
603				out0 = func(in0);
604				${OUTPUT}
605			}
606		""
607	end
608
609
610	case mat3x2
611		version 300 es
612		values
613		{
614			input mat3x2 in0	= [ mat3x2(1.5, -2.5, 2.5, 3.5, 3.0, 0.5) | mat3x2(1.5, -2.0, 2.5, 0.5, -1.5, -3.5) | mat3x2(2.5, 3.5, -3.0, 2.5, -0.5, -2.5) ];
615			output mat3x2 out0	= [ mat3x2(-3.0, 5.0, -5.0, -7.0, -6.0, -1.0) | mat3x2(-3.0, 4.0, -5.0, -1.0, 3.0, 7.0) | mat3x2(-5.0, -7.0, 6.0, -5.0, 1.0, 5.0) ];
616		}
617
618		both ""
619			#version 300 es
620			precision mediump float;
621			${DECLARATIONS}
622
623			mat3x2 func (mat3x2 a)
624			{
625				return -2.0*a;
626			}
627
628			void main()
629			{
630				${SETUP}
631				out0 = func(in0);
632				${OUTPUT}
633			}
634		""
635	end
636
637
638	case mat3
639		version 300 es
640		values
641		{
642			input mat3 in0	= [ mat3(-1.5, 2.0, 3.0, -3.5, 1.0, -3.5, 1.5, -1.5, 3.0) | mat3(3.5, 0.0, 3.5, -1.5, -3.0, 0.5, -3.5, -2.5, -0.5) | mat3(1.0, -2.5, -3.5, 3.0, -1.5, 3.5, 3.0, -1.0, -0.5) ];
643			output mat3 out0	= [ mat3(3.0, -4.0, -6.0, 7.0, -2.0, 7.0, -3.0, 3.0, -6.0) | mat3(-7.0, -0.0, -7.0, 3.0, 6.0, -1.0, 7.0, 5.0, 1.0) | mat3(-2.0, 5.0, 7.0, -6.0, 3.0, -7.0, -6.0, 2.0, 1.0) ];
644		}
645
646		both ""
647			#version 300 es
648			precision mediump float;
649			${DECLARATIONS}
650
651			mat3 func (mat3 a)
652			{
653				return -2.0*a;
654			}
655
656			void main()
657			{
658				${SETUP}
659				out0 = func(in0);
660				${OUTPUT}
661			}
662		""
663	end
664
665
666	case mat3x4
667		version 300 es
668		values
669		{
670			input mat3x4 in0	= [ mat3x4(0.0, 1.0, 0.5, 0.5, 1.0, 3.5, 0.0, -0.5, 1.5, -2.0, -1.5, 3.5) | mat3x4(0.0, 0.5, -3.5, -0.5, 0.5, -3.5, 1.0, 1.0, -3.5, 1.0, -0.5, 1.5) | mat3x4(-1.0, 1.5, 2.0, -3.5, -3.5, 1.5, 3.5, -2.0, -0.5, 0.5, -1.5, -1.0) ];
671			output mat3x4 out0	= [ mat3x4(-0.0, -2.0, -1.0, -1.0, -2.0, -7.0, -0.0, 1.0, -3.0, 4.0, 3.0, -7.0) | mat3x4(-0.0, -1.0, 7.0, 1.0, -1.0, 7.0, -2.0, -2.0, 7.0, -2.0, 1.0, -3.0) | mat3x4(2.0, -3.0, -4.0, 7.0, 7.0, -3.0, -7.0, 4.0, 1.0, -1.0, 3.0, 2.0) ];
672		}
673
674		both ""
675			#version 300 es
676			precision mediump float;
677			${DECLARATIONS}
678
679			mat3x4 func (mat3x4 a)
680			{
681				return -2.0*a;
682			}
683
684			void main()
685			{
686				${SETUP}
687				out0 = func(in0);
688				${OUTPUT}
689			}
690		""
691	end
692
693
694	case mat4x2
695		version 300 es
696		values
697		{
698			input mat4x2 in0	= [ mat4x2(-1.5, -1.0, 0.5, -1.5, -1.0, 2.0, -3.5, 0.5) | mat4x2(2.0, -1.5, -2.0, 2.5, -2.0, -2.5, -0.5, 1.5) | mat4x2(-3.0, -1.5, -1.0, 2.5, -0.5, 2.5, -2.5, -1.0) ];
699			output mat4x2 out0	= [ mat4x2(3.0, 2.0, -1.0, 3.0, 2.0, -4.0, 7.0, -1.0) | mat4x2(-4.0, 3.0, 4.0, -5.0, 4.0, 5.0, 1.0, -3.0) | mat4x2(6.0, 3.0, 2.0, -5.0, 1.0, -5.0, 5.0, 2.0) ];
700		}
701
702		both ""
703			#version 300 es
704			precision mediump float;
705			${DECLARATIONS}
706
707			mat4x2 func (mat4x2 a)
708			{
709				return -2.0*a;
710			}
711
712			void main()
713			{
714				${SETUP}
715				out0 = func(in0);
716				${OUTPUT}
717			}
718		""
719	end
720
721
722	case mat4x3
723		version 300 es
724		values
725		{
726			input mat4x3 in0	= [ mat4x3(1.0, 3.0, -0.5, -2.0, -3.0, 0.0, -2.5, 2.5, 2.5, -2.5, -1.5, 2.5) | mat4x3(1.0, 2.5, -1.0, -3.0, -1.5, 2.0, -1.5, -1.0, -0.5, -0.5, -0.5, 3.0) | mat4x3(-2.5, -3.5, 3.5, 3.0, 3.5, -0.5, 3.5, 3.0, -2.0, 2.0, 2.5, 1.0) ];
727			output mat4x3 out0	= [ mat4x3(-2.0, -6.0, 1.0, 4.0, 6.0, -0.0, 5.0, -5.0, -5.0, 5.0, 3.0, -5.0) | mat4x3(-2.0, -5.0, 2.0, 6.0, 3.0, -4.0, 3.0, 2.0, 1.0, 1.0, 1.0, -6.0) | mat4x3(5.0, 7.0, -7.0, -6.0, -7.0, 1.0, -7.0, -6.0, 4.0, -4.0, -5.0, -2.0) ];
728		}
729
730		both ""
731			#version 300 es
732			precision mediump float;
733			${DECLARATIONS}
734
735			mat4x3 func (mat4x3 a)
736			{
737				return -2.0*a;
738			}
739
740			void main()
741			{
742				${SETUP}
743				out0 = func(in0);
744				${OUTPUT}
745			}
746		""
747	end
748
749
750	case mat4
751		version 300 es
752		values
753		{
754			input mat4 in0	= [ mat4(0.0, -1.5, -1.0, -2.0, -3.0, 0.5, -1.5, 2.5, -3.5, 3.0, 1.5, 3.0, 3.0, 3.0, 0.5, -3.5) | mat4(2.0, -2.5, -1.5, 1.0, 0.0, -0.5, 3.5, 1.0, -1.0, -2.0, 2.5, 0.0, 2.0, -1.0, -2.5, 0.5) | mat4(2.5, -2.5, 2.0, 3.0, 2.5, 2.5, -3.5, 1.0, 2.5, -3.5, -1.5, -1.5, 0.0, -0.5, 0.0, 2.0) ];
755			output mat4 out0	= [ mat4(-0.0, 3.0, 2.0, 4.0, 6.0, -1.0, 3.0, -5.0, 7.0, -6.0, -3.0, -6.0, -6.0, -6.0, -1.0, 7.0) | mat4(-4.0, 5.0, 3.0, -2.0, -0.0, 1.0, -7.0, -2.0, 2.0, 4.0, -5.0, -0.0, -4.0, 2.0, 5.0, -1.0) | mat4(-5.0, 5.0, -4.0, -6.0, -5.0, -5.0, 7.0, -2.0, -5.0, 7.0, 3.0, 3.0, -0.0, 1.0, -0.0, -4.0) ];
756		}
757
758		both ""
759			#version 300 es
760			precision mediump float;
761			${DECLARATIONS}
762
763			mat4 func (mat4 a)
764			{
765				return -2.0*a;
766			}
767
768			void main()
769			{
770				${SETUP}
771				out0 = func(in0);
772				${OUTPUT}
773			}
774		""
775	end
776
777	case float_struct
778		version 300 es
779		values
780		{
781			input vec3 in0		= [ vec3(0.0, 1.0, -2.0) | vec3(2.0, 2.5, -4.0) ];
782			output float out0	= [ 1.0 | -0.5 ];
783		}
784
785		both ""
786			#version 300 es
787			precision mediump float;
788			${DECLARATIONS}
789
790			struct Pos { float a, b, c; };
791
792			float func (Pos p)
793			{
794				return -(p.a + p.b + p.c);
795			}
796
797			void main()
798			{
799				Pos p = Pos(in0.x, in0.y, in0.z);
800				out0 = func(p);
801				${OUTPUT}
802			}
803		""
804	end
805
806	case struct_struct
807		version 300 es
808		values
809		{
810			input vec3 in0		= [ vec3(0.0, 1.0, -2.0) | vec3(2.0, 2.5, -4.0) ];
811			output float out0	= [ 1.0 | -0.5 ];
812		}
813
814		both ""
815			#version 300 es
816			precision mediump float;
817			${DECLARATIONS}
818
819			struct Pos { float a, b, c; };
820
821			Pos func (Pos p)
822			{
823				return Pos(-p.a, -p.b, -p.c);
824			}
825
826			void main()
827			{
828				Pos p = Pos(in0.x, in0.y, in0.z);
829				p = func(p);
830				out0 = p.a + p.b + p.c;
831				${OUTPUT}
832			}
833		""
834	end
835
836	case struct_nested_struct
837		version 300 es
838		values
839		{
840			input vec3 in0		= [ vec3(0.0, 1.0, -2.0) | vec3(2.0, 2.5, -4.0) ];
841			output float out0	= [ 1.0 | -0.5 ];
842		}
843
844		both ""
845			#version 300 es
846			precision mediump float;
847			${DECLARATIONS}
848
849			struct Pos { float a, b, c; };
850			struct Line { Pos start, end; };
851
852			Line func (Pos p)
853			{
854				return Line(p, Pos(-p.a, -p.b, -p.c));
855			}
856
857			float sum (Pos p)
858			{
859				return (p.a + p.b + p.c);
860			}
861
862			void main()
863			{
864				Pos p = Pos(in0.x, in0.y, in0.z);
865				Line line = func(p);
866				out0 = sum(line.start) + (2.0 * sum(line.end));
867				${OUTPUT}
868			}
869		""
870	end
871
872
873end # datatypes
874
875group qualifiers "Function Parameter Qualifiers"
876
877	case in_float
878		version 300 es
879		values
880		{
881			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
882			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
883		}
884
885		both ""
886			#version 300 es
887			precision mediump float;
888			precision mediump int;
889			${DECLARATIONS}
890
891			float func (in float a)
892			{
893				a = -a;
894				return 2.0 * a;
895			}
896
897			void main()
898			{
899				${SETUP}
900				float f = in0;
901				float g = func(f);
902				out0 = f + g;
903				${OUTPUT}
904			}
905		""
906	end
907
908	case out_float
909		version 300 es
910		values
911		{
912			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
913			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
914		}
915
916		both ""
917			#version 300 es
918			precision mediump float;
919			precision mediump int;
920			${DECLARATIONS}
921
922			void func (out float a)
923			{
924				a = -1.0;
925			}
926
927			void main()
928			{
929				${SETUP}
930				float f = 1.0;
931				func(f);
932				out0 = f * in0;
933				${OUTPUT}
934			}
935		""
936	end
937
938	case inout_float
939		version 300 es
940		values
941		{
942			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
943			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
944		}
945
946		both ""
947			#version 300 es
948			precision mediump float;
949			precision mediump int;
950			${DECLARATIONS}
951
952			void func (inout float a)
953			{
954				a = -a;
955			}
956
957			void main()
958			{
959				${SETUP}
960				float f = 1.0;
961				func(f);
962				out0 = f * in0;
963				${OUTPUT}
964			}
965		""
966	end
967
968	case in_lowp_float
969		version 300 es
970		values
971		{
972			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
973			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
974		}
975
976		both ""
977			#version 300 es
978			precision mediump float;
979			precision mediump int;
980			${DECLARATIONS}
981
982			float func (in lowp float a)
983			{
984				a = -a;
985				return 2.0 * a;
986			}
987
988			void main()
989			{
990				${SETUP}
991				float f = in0;
992				float g = func(f);
993				out0 = f + g;
994				${OUTPUT}
995			}
996		""
997	end
998
999	case out_lowp_float
1000		version 300 es
1001		values
1002		{
1003			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1004			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1005		}
1006
1007		both ""
1008			#version 300 es
1009			precision mediump float;
1010			precision mediump int;
1011			${DECLARATIONS}
1012
1013			void func (out lowp float a)
1014			{
1015				a = -1.0;
1016			}
1017
1018			void main()
1019			{
1020				${SETUP}
1021				float f = 1.0;
1022				func(f);
1023				out0 = f * in0;
1024				${OUTPUT}
1025			}
1026		""
1027	end
1028
1029	case inout_lowp_float
1030		version 300 es
1031		values
1032		{
1033			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1034			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1035		}
1036
1037		both ""
1038			#version 300 es
1039			precision mediump float;
1040			precision mediump int;
1041			${DECLARATIONS}
1042
1043			void func (inout lowp float a)
1044			{
1045				a = -a;
1046			}
1047
1048			void main()
1049			{
1050				${SETUP}
1051				float f = 1.0;
1052				func(f);
1053				out0 = f * in0;
1054				${OUTPUT}
1055			}
1056		""
1057	end
1058
1059	case in_highp_float
1060		version 300 es
1061		values
1062		{
1063			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1064			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1065		}
1066
1067		both ""
1068			#version 300 es
1069			precision mediump float;
1070			precision mediump int;
1071			${DECLARATIONS}
1072
1073			float func (in highp float a)
1074			{
1075				a = -a;
1076				return 2.0 * a;
1077			}
1078
1079			void main()
1080			{
1081				${SETUP}
1082				float f = in0;
1083				float g = func(f);
1084				out0 = f + g;
1085				${OUTPUT}
1086			}
1087		""
1088	end
1089
1090	case out_highp_float
1091		version 300 es
1092		values
1093		{
1094			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1095			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1096		}
1097
1098		both ""
1099			#version 300 es
1100			precision mediump float;
1101			precision mediump int;
1102			${DECLARATIONS}
1103
1104			void func (out highp float a)
1105			{
1106				a = -1.0;
1107			}
1108
1109			void main()
1110			{
1111				${SETUP}
1112				float f = 1.0;
1113				func(f);
1114				out0 = f * in0;
1115				${OUTPUT}
1116			}
1117		""
1118	end
1119
1120	case inout_highp_float
1121		version 300 es
1122		values
1123		{
1124			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1125			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1126		}
1127
1128		both ""
1129			#version 300 es
1130			precision mediump float;
1131			precision mediump int;
1132			${DECLARATIONS}
1133
1134			void func (inout highp float a)
1135			{
1136				a = -a;
1137			}
1138
1139			void main()
1140			{
1141				${SETUP}
1142				float f = 1.0;
1143				func(f);
1144				out0 = f * in0;
1145				${OUTPUT}
1146			}
1147		""
1148	end
1149
1150	case const_float
1151		version 300 es
1152		values
1153		{
1154			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1155			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1156		}
1157
1158		both ""
1159			#version 300 es
1160			precision mediump float;
1161			precision mediump int;
1162			${DECLARATIONS}
1163
1164			float func (const float a)
1165			{
1166				float b = -a;
1167				return 2.0 * b;
1168			}
1169
1170			void main()
1171			{
1172				${SETUP}
1173				float f = in0;
1174				float g = func(f);
1175				out0 = f + g;
1176				${OUTPUT}
1177			}
1178		""
1179	end
1180
1181	case const_in_float
1182		version 300 es
1183		values
1184		{
1185			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1186			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1187		}
1188
1189		both ""
1190			#version 300 es
1191			precision mediump float;
1192			precision mediump int;
1193			${DECLARATIONS}
1194
1195			float func (const in float a)
1196			{
1197				float b = -a;
1198				return 2.0 * b;
1199			}
1200
1201			void main()
1202			{
1203				${SETUP}
1204				float f = in0;
1205				float g = func(f);
1206				out0 = f + g;
1207				${OUTPUT}
1208			}
1209		""
1210	end
1211
1212	case in_int
1213		version 300 es
1214		values
1215		{
1216			input int in0		= [ 0 | 1 | -2 | 4 ];
1217			output int out0		= [ 0 | -1 | 2 | -4 ];
1218		}
1219
1220		both ""
1221			#version 300 es
1222			precision mediump float;
1223			precision mediump int;
1224			${DECLARATIONS}
1225
1226			int func (in int a)
1227			{
1228				a = -a;
1229				return 2 * a;
1230			}
1231
1232			void main()
1233			{
1234				${SETUP}
1235				int f = in0;
1236				int g = func(f);
1237				out0 = f + g;
1238				${OUTPUT}
1239			}
1240		""
1241	end
1242
1243	case out_int
1244		version 300 es
1245		values
1246		{
1247			input int in0		= [ 0 | 1 | -2 | 6 ];
1248			output int out0		= [ 0 | -1 | 2 | -6 ];
1249		}
1250
1251		both ""
1252			#version 300 es
1253			precision mediump float;
1254			precision mediump int;
1255			${DECLARATIONS}
1256
1257			void func (out int a)
1258			{
1259				a = -1;
1260			}
1261
1262			void main()
1263			{
1264				${SETUP}
1265				int f = 1;
1266				func(f);
1267				out0 = f * in0;
1268				${OUTPUT}
1269			}
1270		""
1271	end
1272
1273	case inout_int
1274		version 300 es
1275		values
1276		{
1277			input int in0		= [ 0 | 1 | -2 | 6 ];
1278			output int out0		= [ 0 | -1 | 2 | -6 ];
1279		}
1280
1281		both ""
1282			#version 300 es
1283			precision mediump float;
1284			precision mediump int;
1285			${DECLARATIONS}
1286
1287			void func (inout int a)
1288			{
1289				a = -a;
1290			}
1291
1292			void main()
1293			{
1294				${SETUP}
1295				int f = 1;
1296				func(f);
1297				out0 = f * in0;
1298				${OUTPUT}
1299			}
1300		""
1301	end
1302
1303	case in_lowp_int
1304		version 300 es
1305		values
1306		{
1307			input int in0		= [ 0 | 1 | -2 | 4 ];
1308			output int out0		= [ 0 | -1 | 2 | -4 ];
1309		}
1310
1311		both ""
1312			#version 300 es
1313			precision mediump float;
1314			precision mediump int;
1315			${DECLARATIONS}
1316
1317			int func (in lowp int a)
1318			{
1319				a = -a;
1320				return 2 * a;
1321			}
1322
1323			void main()
1324			{
1325				${SETUP}
1326				int f = in0;
1327				int g = func(f);
1328				out0 = f + g;
1329				${OUTPUT}
1330			}
1331		""
1332	end
1333
1334	case out_lowp_int
1335		version 300 es
1336		values
1337		{
1338			input int in0		= [ 0 | 1 | -2 | 6 ];
1339			output int out0		= [ 0 | -1 | 2 | -6 ];
1340		}
1341
1342		both ""
1343			#version 300 es
1344			precision mediump float;
1345			precision mediump int;
1346			${DECLARATIONS}
1347
1348			void func (out lowp int a)
1349			{
1350				a = -1;
1351			}
1352
1353			void main()
1354			{
1355				${SETUP}
1356				int f = 1;
1357				func(f);
1358				out0 = f * in0;
1359				${OUTPUT}
1360			}
1361		""
1362	end
1363
1364	case inout_lowp_int
1365		version 300 es
1366		values
1367		{
1368			input int in0		= [ 0 | 1 | -2 | 6 ];
1369			output int out0		= [ 0 | -1 | 2 | -6 ];
1370		}
1371
1372		both ""
1373			#version 300 es
1374			precision mediump float;
1375			precision mediump int;
1376			${DECLARATIONS}
1377
1378			void func (inout lowp int a)
1379			{
1380				a = -a;
1381			}
1382
1383			void main()
1384			{
1385				${SETUP}
1386				int f = 1;
1387				func(f);
1388				out0 = f * in0;
1389				${OUTPUT}
1390			}
1391		""
1392	end
1393
1394	case in_highp_int
1395		version 300 es
1396		values
1397		{
1398			input int in0		= [ 0 | 1 | -2 | 4 ];
1399			output int out0		= [ 0 | -1 | 2 | -4 ];
1400		}
1401
1402		both ""
1403			#version 300 es
1404			precision mediump float;
1405			precision mediump int;
1406			${DECLARATIONS}
1407
1408			int func (in highp int a)
1409			{
1410				a = -a;
1411				return 2 * a;
1412			}
1413
1414			void main()
1415			{
1416				${SETUP}
1417				int f = in0;
1418				int g = func(f);
1419				out0 = f + g;
1420				${OUTPUT}
1421			}
1422		""
1423	end
1424
1425	case out_highp_int
1426		version 300 es
1427		values
1428		{
1429			input int in0		= [ 0 | 1 | -2 | 6 ];
1430			output int out0		= [ 0 | -1 | 2 | -6 ];
1431		}
1432
1433		both ""
1434			#version 300 es
1435			precision mediump float;
1436			precision mediump int;
1437			${DECLARATIONS}
1438
1439			void func (out highp int a)
1440			{
1441				a = -1;
1442			}
1443
1444			void main()
1445			{
1446				${SETUP}
1447				int f = 1;
1448				func(f);
1449				out0 = f * in0;
1450				${OUTPUT}
1451			}
1452		""
1453	end
1454
1455	case inout_highp_int
1456		version 300 es
1457		values
1458		{
1459			input int in0		= [ 0 | 1 | -2 | 6 ];
1460			output int out0		= [ 0 | -1 | 2 | -6 ];
1461		}
1462
1463		both ""
1464			#version 300 es
1465			precision mediump float;
1466			precision mediump int;
1467			${DECLARATIONS}
1468
1469			void func (inout highp int a)
1470			{
1471				a = -a;
1472			}
1473
1474			void main()
1475			{
1476				${SETUP}
1477				int f = 1;
1478				func(f);
1479				out0 = f * in0;
1480				${OUTPUT}
1481			}
1482		""
1483	end
1484
1485	case const_int
1486		version 300 es
1487		values
1488		{
1489			input int in0		= [ 0 | 1 | -2 | 4 ];
1490			output int out0		= [ 0 | -1 | 2 | -4 ];
1491		}
1492
1493		both ""
1494			#version 300 es
1495			precision mediump float;
1496			precision mediump int;
1497			${DECLARATIONS}
1498
1499			int func (const int a)
1500			{
1501				int b = -a;
1502				return 2 * b;
1503			}
1504
1505			void main()
1506			{
1507				${SETUP}
1508				int f = in0;
1509				int g = func(f);
1510				out0 = f + g;
1511				${OUTPUT}
1512			}
1513		""
1514	end
1515
1516	case const_in_int
1517		version 300 es
1518		values
1519		{
1520			input int in0		= [ 0 | 1 | -2 | 4 ];
1521			output int out0		= [ 0 | -1 | 2 | -4 ];
1522		}
1523
1524		both ""
1525			#version 300 es
1526			precision mediump float;
1527			precision mediump int;
1528			${DECLARATIONS}
1529
1530			int func (const in int a)
1531			{
1532				int b = -a;
1533				return 2 * b;
1534			}
1535
1536			void main()
1537			{
1538				${SETUP}
1539				int f = in0;
1540				int g = func(f);
1541				out0 = f + g;
1542				${OUTPUT}
1543			}
1544		""
1545	end
1546
1547	case in_bool
1548		version 300 es
1549		values
1550		{
1551			input bool in0		= [ true | false ];
1552			output bool out0	= [ true | true ];
1553		}
1554
1555		both ""
1556			#version 300 es
1557			precision mediump float;
1558			${DECLARATIONS}
1559
1560			bool func (in bool a)
1561			{
1562				a = !a;
1563				return a;
1564			}
1565
1566			void main()
1567			{
1568				${SETUP}
1569				bool f = in0;
1570				bool g = func(f);
1571				out0 = (f != g);
1572				${OUTPUT}
1573			}
1574		""
1575	end
1576
1577	case out_bool
1578		version 300 es
1579		values
1580		{
1581			input bool in0		= [ true | false ];
1582			output bool out0	= [ false | true ];
1583		}
1584
1585		both ""
1586			#version 300 es
1587			precision mediump float;
1588			${DECLARATIONS}
1589
1590			void func (out bool a)
1591			{
1592				a = false;
1593			}
1594
1595			void main()
1596			{
1597				${SETUP}
1598				bool f = true;
1599				func(f);
1600				out0 = (in0 == f);
1601				${OUTPUT}
1602			}
1603		""
1604	end
1605
1606	case inout_bool
1607		version 300 es
1608		values
1609		{
1610			input bool in0		= [ true | false ];
1611			output bool out0	= [ false | true ];
1612		}
1613
1614		both ""
1615			#version 300 es
1616			precision mediump float;
1617			${DECLARATIONS}
1618
1619			void func (inout bool a)
1620			{
1621				a = !a;
1622			}
1623
1624			void main()
1625			{
1626				${SETUP}
1627				bool f = true;
1628				func(f);
1629				out0 = (in0 == f);
1630				${OUTPUT}
1631			}
1632		""
1633	end
1634
1635	case const_bool
1636		version 300 es
1637		values
1638		{
1639			input bool in0		= [ true | false ];
1640			output bool out0	= [ true | true ];
1641		}
1642
1643		both ""
1644			#version 300 es
1645			precision mediump float;
1646			${DECLARATIONS}
1647
1648			bool func (const bool a)
1649			{
1650				bool b = !a;
1651				return b;
1652			}
1653
1654			void main()
1655			{
1656				${SETUP}
1657				bool f = in0;
1658				bool g = func(f);
1659				out0 = (f != g);
1660				${OUTPUT}
1661			}
1662		""
1663	end
1664
1665end # qualifiers
1666
1667group declarations "Function Declarations"
1668
1669	case basic
1670		version 300 es
1671		values
1672		{
1673			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1674			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1675		}
1676
1677		both ""
1678			#version 300 es
1679			precision mediump float;
1680			${DECLARATIONS}
1681
1682			float func (void);
1683
1684			float func (void)
1685			{
1686				return -1.0;
1687			}
1688
1689			void main()
1690			{
1691				out0 = func() * in0;
1692				${OUTPUT}
1693			}
1694		""
1695	end
1696
1697	case basic_arg
1698		version 300 es
1699		values
1700		{
1701			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1702			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1703		}
1704
1705		both ""
1706			#version 300 es
1707			precision mediump float;
1708			${DECLARATIONS}
1709
1710			float func (float f);
1711
1712			float func (float f)
1713			{
1714				return -f;
1715			}
1716
1717			void main()
1718			{
1719				out0 = func(in0);
1720				${OUTPUT}
1721			}
1722		""
1723	end
1724
1725	case define_after_use
1726		version 300 es
1727		values
1728		{
1729			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1730			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1731		}
1732
1733		both ""
1734			#version 300 es
1735			precision mediump float;
1736			${DECLARATIONS}
1737
1738			float func (void);
1739
1740			void main()
1741			{
1742				out0 = func() * in0;
1743				${OUTPUT}
1744			}
1745
1746			float func (void)
1747			{
1748				return -1.0;
1749			}
1750		""
1751	end
1752
1753	case double_declare
1754		version 300 es
1755		values
1756		{
1757			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1758			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1759		}
1760
1761		both ""
1762			#version 300 es
1763			precision mediump float;
1764			${DECLARATIONS}
1765
1766			float func (void);
1767
1768			float func (void);
1769
1770			float func (void)
1771			{
1772				return -1.0;
1773			}
1774
1775			void main()
1776			{
1777				out0 = func() * in0;
1778				${OUTPUT}
1779			}
1780		""
1781	end
1782
1783	case declare_after_define
1784		version 300 es
1785		values
1786		{
1787			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1788			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1789		}
1790
1791		both ""
1792			#version 300 es
1793			precision mediump float;
1794			${DECLARATIONS}
1795
1796			float func (void)
1797			{
1798				return -1.0;
1799			}
1800
1801			float func (void);
1802
1803			void main()
1804			{
1805				out0 = func() * in0;
1806				${OUTPUT}
1807			}
1808		""
1809	end
1810
1811	case void_vs_no_void
1812		version 300 es
1813		values
1814		{
1815			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1816			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1817		}
1818
1819		both ""
1820			#version 300 es
1821			precision mediump float;
1822			${DECLARATIONS}
1823
1824			float func ();
1825
1826			void main()
1827			{
1828				out0 = func() * in0;
1829				${OUTPUT}
1830			}
1831
1832			float func (void)
1833			{
1834				return -1.0;
1835			}
1836		""
1837	end
1838
1839	case in_vs_no_in
1840		version 300 es
1841		values
1842		{
1843			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1844			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1845		}
1846
1847		both ""
1848			#version 300 es
1849			precision mediump float;
1850			${DECLARATIONS}
1851
1852			float func (float f);
1853
1854			void main()
1855			{
1856				out0 = func(in0);
1857				${OUTPUT}
1858			}
1859
1860			float func (in float f)
1861			{
1862				return -f;
1863			}
1864		""
1865	end
1866
1867	case default_vs_explicit_precision
1868		version 300 es
1869		values
1870		{
1871			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1872			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1873		}
1874
1875		both ""
1876			#version 300 es
1877			precision mediump float;
1878			${DECLARATIONS}
1879
1880			float func (float f);
1881
1882			void main()
1883			{
1884				out0 = func(in0);
1885				${OUTPUT}
1886			}
1887
1888			float func (mediump float f)
1889			{
1890				return -f;
1891			}
1892		""
1893	end
1894
1895
1896end # declarations
1897
1898group overloading "Function Overloading"
1899
1900	case user_func_arg_type_simple
1901		version 300 es
1902		values
1903		{
1904			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1905			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1906		}
1907
1908		both ""
1909			#version 300 es
1910			precision mediump float;
1911			precision mediump int;
1912			${DECLARATIONS}
1913
1914			float func (float a)
1915			{
1916				return -a;
1917			}
1918
1919			int func (int a)
1920			{
1921				return -a;
1922			}
1923
1924			void main()
1925			{
1926				out0 = func(in0) * float(func(-1));
1927				${OUTPUT}
1928			}
1929		""
1930	end
1931
1932	case user_func_arg_float_types
1933		version 300 es
1934		values
1935		{
1936			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
1937			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
1938		}
1939
1940		both ""
1941			#version 300 es
1942			precision mediump float;
1943			precision mediump int;
1944			${DECLARATIONS}
1945
1946			float func (float a) { return -a; }
1947			vec2 func (vec2 a) { return a.yx; }
1948			vec3 func (vec3 a) { return a.xxx; }
1949			vec4 func (vec4 a) { return a.wwww; }
1950
1951			void main()
1952			{
1953				out0 = func(func(func(func(vec4(in0)).xyz).xy).x);
1954				${OUTPUT}
1955			}
1956		""
1957	end
1958
1959	case user_func_arg_int_types
1960		version 300 es
1961		values
1962		{
1963			input int in0		= [ 0 | 1 | -2 | 6 ];
1964			output int out0		= [ 0 | -1 | 2 | -6 ];
1965		}
1966
1967		both ""
1968			#version 300 es
1969			precision mediump float;
1970			precision mediump int;
1971			${DECLARATIONS}
1972
1973			int func (int a) { return -a; }
1974			ivec2 func (ivec2 a) { return a.yx; }
1975			ivec3 func (ivec3 a) { return a.xxx; }
1976			ivec4 func (ivec4 a) { return a.wwww; }
1977
1978			void main()
1979			{
1980				${SETUP}
1981				out0 = func(func(func(func(ivec4(in0)).xyz).xy).x);
1982				${OUTPUT}
1983			}
1984		""
1985	end
1986
1987	case user_func_arg_bool_types
1988		version 300 es
1989		values
1990		{
1991			input bool in0		= [ true | false ];
1992			output bool out0	= [ false | true ];
1993		}
1994
1995		both ""
1996			#version 300 es
1997			precision mediump float;
1998			${DECLARATIONS}
1999
2000			bool func (bool a) { return !a; }
2001			bvec2 func (bvec2 a) { return a.yx; }
2002			bvec3 func (bvec3 a) { return a.xxx; }
2003			bvec4 func (bvec4 a) { return a.wwww; }
2004
2005			void main()
2006			{
2007				${SETUP}
2008				out0 = func(func(func(func(bvec4(in0)).xyz).xy).x);
2009				${OUTPUT}
2010			}
2011		""
2012	end
2013
2014	case user_func_arg_basic_types
2015		version 300 es
2016		values
2017		{
2018			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
2019			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
2020		}
2021
2022		both ""
2023			#version 300 es
2024			precision mediump float;
2025			precision mediump int;
2026			${DECLARATIONS}
2027
2028			float func (float a) { return -a; }
2029			vec2 func (vec2 a) { return a.yx; }
2030			vec3 func (vec3 a) { return a.xxx; }
2031			vec4 func (vec4 a) { return a.wwww; }
2032			int func (int a) { return -a; }
2033			ivec2 func (ivec2 a) { return a.yx; }
2034			ivec3 func (ivec3 a) { return a.xxx; }
2035			ivec4 func (ivec4 a) { return a.wwww; }
2036			bool func (bool a) { return !a; }
2037			bvec2 func (bvec2 a) { return a.yx; }
2038			bvec3 func (bvec3 a) { return a.xxx; }
2039			bvec4 func (bvec4 a) { return a.wwww; }
2040
2041			void main()
2042			{
2043				${SETUP}
2044				if (func(func(bvec4(false)).x))
2045					out0 = func(in0) * float(func(-1));
2046				else
2047					out0 = float(func(func(ivec4(func(func(func(vec4(0.5)).xyz).xy).xxxx)).xy).x);
2048				${OUTPUT}
2049			}
2050		""
2051	end
2052
2053	case user_func_arg_complex_types
2054		version 300 es
2055		values
2056		{
2057			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
2058			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
2059		}
2060
2061		both ""
2062			#version 300 es
2063			precision mediump float;
2064			precision mediump int;
2065			${DECLARATIONS}
2066
2067			struct Pos { float a, b, c; };
2068			struct Line { Pos start, end; };
2069
2070			float func (float a) { return -a; }
2071			float func (float a[4]) { return a[0] + a[3]; }
2072			vec2 func (vec2 a) { return a.yx; }
2073			vec3 func (vec3 a) { return a.xxx; }
2074			vec4 func (vec4 a) { return a.wwww; }
2075			vec4 func (vec4 a[4]) { return a[1] + a[2]; }
2076			int func (int a) { return -a; }
2077			ivec2 func (ivec2 a) { return a.yx; }
2078			ivec3 func (ivec3 a) { return a.xxx; }
2079			ivec4 func (ivec4 a) { return a.wwww; }
2080			bool func (bool a) { return !a; }
2081			bvec2 func (bvec2 a) { return a.yx; }
2082			bvec3 func (bvec3 a) { return a.xxx; }
2083			bvec4 func (bvec4 a) { return a.wwww; }
2084			Pos func (Pos a) { return a; }
2085			Line func (Line a) { return Line(a.end, a.start); }
2086
2087			void main()
2088			{
2089				${SETUP}
2090				float arr[4];
2091				vec4 arr2[4];
2092				out0 = func(arr) + func(arr2).x;
2093				if (func(func(bvec4(false)).x))
2094					out0 = func(in0) * float(func(-1));
2095				else
2096					out0 = float(func(func(ivec4(func(func(func(vec4(0.5)).xyz).xy).xxxx)).xy).x);
2097				${OUTPUT}
2098			}
2099		""
2100	end
2101
2102	case user_func_arguments
2103		version 300 es
2104		values
2105		{
2106			input float in0		= [ 0.0 | 1.0 | -2.0 | 2.5 ];
2107			output float out0	= [ 0.0 | -1.0 | 2.0 | -2.5 ];
2108		}
2109
2110		both ""
2111			#version 300 es
2112			precision mediump float;
2113			${DECLARATIONS}
2114
2115			float func (float a)
2116			{
2117				return -a;
2118			}
2119
2120			float func (float a, float b)
2121			{
2122				return a * b;
2123			}
2124
2125			void main()
2126			{
2127				out0 = func(in0) * func(-0.5, -2.0);
2128				${OUTPUT}
2129			}
2130		""
2131	end
2132
2133	case array_size
2134		version 300 es
2135		values
2136		{
2137			output float out0	= [ 1.0 ];
2138		}
2139
2140		both ""
2141			#version 300 es
2142			precision mediump float;
2143			${DECLARATIONS}
2144
2145			float func (float f[3])
2146			{
2147				return f[0];
2148			}
2149
2150			float func (float f[4])
2151			{
2152				return f[1];
2153			}
2154
2155			void main ()
2156			{
2157				${SETUP}
2158				float[4] x = float[4] (-1.0, 1.0, 0.0, 0.0);
2159				out0 = func(x);
2160				${OUTPUT}
2161			}
2162		""
2163	end
2164
2165end # overloading
2166
2167group array_arguments "Arrays as Arguments"
2168
2169	case local_in_float
2170		version 300 es
2171		values
2172		{
2173			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2174			output vec4 out0	= [ vec4(0.0, -1.0, -2.0, 4.0) | vec4(7.5, -12.125, 0.25, -16.0) ];
2175		}
2176
2177		both ""
2178			#version 300 es
2179			precision mediump float;
2180			${DECLARATIONS}
2181
2182			float func (in float a[4])
2183			{
2184				a[0] = -1.0;
2185				a[2] = -4.0;
2186				a[3] = -3.0 * a[1];
2187				return a[0];
2188			}
2189
2190			void main()
2191			{
2192				float arr[4];
2193				arr[0] = in0.x;
2194				arr[1] = in0.y;
2195				arr[2] = in0.z;
2196				arr[3] = in0.w;
2197				float f = func(arr);
2198				out0 = f * vec4(arr[0], arr[1], arr[2], arr[3]);
2199				${OUTPUT}
2200			}
2201		""
2202	end
2203
2204	case global_in_float
2205		version 300 es
2206		values
2207		{
2208			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2209			output vec4 out0	= [ vec4(0.0, -1.0, -2.0, 4.0) | vec4(7.5, -12.125, 0.25, -16.0) ];
2210		}
2211
2212		both ""
2213			#version 300 es
2214			precision mediump float;
2215			${DECLARATIONS}
2216
2217			float func (in float a[4])
2218			{
2219				a[0] = -1.0;
2220				a[2] = -4.0;
2221				a[3] = -3.0 * a[1];
2222				return a[0];
2223			}
2224
2225			float arr[4];
2226
2227			void main()
2228			{
2229				arr[0] = in0.x;
2230				arr[1] = in0.y;
2231				arr[2] = in0.z;
2232				arr[3] = in0.w;
2233				float f = func(arr);
2234				out0 = f * vec4(arr[0], arr[1], arr[2], arr[3]);
2235				${OUTPUT}
2236			}
2237		""
2238	end
2239
2240	case local_in_int
2241		version 300 es
2242		values
2243		{
2244			input ivec4 in0		= [ ivec4(0, 1, 2, -4) | ivec4(-7, -11, 13, 19) ];
2245			output ivec4 out0	= [ ivec4(0, -1, -2, 4) | ivec4(7, 11, -13, -19) ];
2246		}
2247
2248		both ""
2249			#version 300 es
2250			precision mediump float;
2251			precision mediump int;
2252			${DECLARATIONS}
2253
2254			int func (in int a[4])
2255			{
2256				a[0] = -1;
2257				a[2] = -4;
2258				a[3] = -3 * a[1];
2259				return a[0];
2260			}
2261
2262			void main()
2263			{
2264				${SETUP}
2265				int arr[4];
2266				arr[0] = in0.x;
2267				arr[1] = in0.y;
2268				arr[2] = in0.z;
2269				arr[3] = in0.w;
2270				int f = func(arr);
2271				out0 = f * ivec4(arr[0], arr[1], arr[2], arr[3]);
2272				${OUTPUT}
2273			}
2274		""
2275	end
2276
2277	case global_in_int
2278		version 300 es
2279		values
2280		{
2281			input ivec4 in0		= [ ivec4(0, 1, 2, 4) | ivec4(-7, -11, 13, 19) ];
2282			output ivec4 out0	= [ ivec4(0, -1, -2, -4) | ivec4(7, 11, -13, -19) ];
2283		}
2284
2285		both ""
2286			#version 300 es
2287			precision mediump float;
2288			precision mediump int;
2289			${DECLARATIONS}
2290
2291			int func (in int a[4])
2292			{
2293				a[0] = -1;
2294				a[2] = -4;
2295				a[3] = -3 * a[1];
2296				return a[0];
2297			}
2298
2299			int arr[4];
2300
2301			void main()
2302			{
2303				${SETUP}
2304				arr[0] = in0.x;
2305				arr[1] = in0.y;
2306				arr[2] = in0.z;
2307				arr[3] = in0.w;
2308				int f = func(arr);
2309				out0 = f * ivec4(arr[0], arr[1], arr[2], arr[3]);
2310				${OUTPUT}
2311			}
2312
2313		""
2314	end
2315
2316	case local_in_bool
2317		version 300 es
2318		values
2319		{
2320			input bvec4 in0		= [ bvec4(true, true, false, true) | bvec4(false, false, false, false) ];
2321			output bvec4 out0	= [ bvec4(false, false, true, false) | bvec4(true, true, true, true) ];
2322		}
2323
2324		both ""
2325			#version 300 es
2326			precision mediump float;
2327			${DECLARATIONS}
2328
2329			bool func (in bool a[4])
2330			{
2331				a[0] = false;
2332				a[2] = true;
2333				a[3] = !a[1];
2334				return a[0];
2335			}
2336
2337			void main()
2338			{
2339				${SETUP}
2340				bool arr[4];
2341				arr[0] = !in0.x;
2342				arr[1] = !in0.y;
2343				arr[2] = !in0.z;
2344				arr[3] = !in0.w;
2345				func(arr);
2346				out0 = bvec4(arr[0], arr[1], arr[2], arr[3]);
2347				${OUTPUT}
2348			}
2349		""
2350	end
2351
2352	case global_in_bool
2353		version 300 es
2354		values
2355		{
2356			input bvec4 in0		= [ bvec4(true, true, false, true) | bvec4(false, false, false, false) ];
2357			output bvec4 out0	= [ bvec4(false, false, true, false) | bvec4(true, true, true, true) ];
2358		}
2359
2360		both ""
2361			#version 300 es
2362			precision mediump float;
2363			${DECLARATIONS}
2364
2365			bool func (in bool a[4])
2366			{
2367				a[0] = false;
2368				a[2] = true;
2369				a[3] = !a[1];
2370				return a[0];
2371			}
2372
2373			bool arr[4];
2374
2375			void main()
2376			{
2377				${SETUP}
2378				arr[0] = !in0.x;
2379				arr[1] = !in0.y;
2380				arr[2] = !in0.z;
2381				arr[3] = !in0.w;
2382				func(arr);
2383				out0 = bvec4(arr[0], arr[1], arr[2], arr[3]);
2384				${OUTPUT}
2385			}
2386		""
2387	end
2388
2389	case test_helpers
2390		version 300 es
2391		desc "Check that helper functions are supported properly."
2392		values
2393		{
2394			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2395			output float out0	= [ 1.0 | 1.0 ];
2396		}
2397
2398		both ""
2399			#version 300 es
2400			precision mediump float;
2401			${DECLARATIONS}
2402
2403			vec4 get (in float arr[4]);
2404			void set (out float arr[4], vec4 val);
2405			void negate (inout float arr[4]);
2406			bool test (in float arr[4], vec4 ref);
2407			bool isEqual (in float a[4], in float b[4]);
2408
2409			void main()
2410			{
2411				float arr[4];
2412				set(arr, in0);
2413				negate(arr);
2414				out0 = float(test(arr, -in0));
2415				${OUTPUT}
2416			}
2417
2418			float absDiff (vec4 a, vec4 b) { vec4 d = abs(a - b); return max(max(d.x, d.y), max(d.z, d.w)); }
2419			vec4 get (in float arr[4]) { return vec4(arr[0], arr[1], arr[2], arr[3]); }
2420			void set (out float arr[4], vec4 val) { arr[0] = val.x; arr[1] = val.y; arr[2] = val.z; arr[3] = val.w; }
2421			void negate (inout float arr[4]) { set(arr, -get(arr)); }
2422			bool test (in float arr[4], vec4 ref) { return (absDiff(get(arr), ref) < 0.1); }
2423			bool isEqual (in float a[4], in float b[4]) { return (absDiff(get(a), get(b)) < 0.1); }
2424		""
2425	end
2426
2427	case copy_local_in_on_call
2428		version 300 es
2429		desc "Check that local 'in' arguments are copied on call and don't alias."
2430		values
2431		{
2432			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2433			output vec4 out0	= [ vec4(0.0, -1.0, -2.0, 4.0) | vec4(7.5, -12.125, 0.25, -16.0) ];
2434		}
2435
2436		both ""
2437			#version 300 es
2438			precision mediump float;
2439			${DECLARATIONS}
2440
2441			vec4 get (in float arr[4]);
2442			void set (out float arr[4], vec4 val);
2443			void negate (inout float arr[4]);
2444			bool test (in float arr[4], vec4 ref);
2445			bool isEqual (in float a[4], in float b[4]);
2446
2447			float func (in float a[4], in float b[4])
2448			{
2449				a[0] = 2.123;
2450				a[2] = -4.123;
2451				return isEqual(a, b) ? 1.0 : -1.0;
2452			}
2453
2454			void main()
2455			{
2456				float arr[4];
2457				set(arr, in0);
2458				out0 = in0 * func(arr, arr);
2459				${OUTPUT}
2460			}
2461
2462			float absDiff (vec4 a, vec4 b) { vec4 d = abs(a - b); return max(max(d.x, d.y), max(d.z, d.w)); }
2463			vec4 get (in float arr[4]) { return vec4(arr[0], arr[1], arr[2], arr[3]); }
2464			void set (out float arr[4], vec4 val) { arr[0] = val.x; arr[1] = val.y; arr[2] = val.z; arr[3] = val.w; }
2465			void negate (inout float arr[4]) { set(arr, -get(arr)); }
2466			bool test (in float arr[4], vec4 ref) { return (absDiff(get(arr), ref) < 0.1); }
2467			bool isEqual (in float a[4], in float b[4]) { return (absDiff(get(a), get(b)) < 0.1); }
2468		""
2469	end
2470
2471	case copy_global_in_on_call
2472		version 300 es
2473		desc "Check that global 'in' arguments are copied on call and don't alias."
2474		values
2475		{
2476			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2477			output vec4 out0	= [ vec4(0.0, -1.0, -2.0, 4.0) | vec4(7.5, -12.125, 0.25, -16.0) ];
2478		}
2479
2480		both ""
2481			#version 300 es
2482			precision mediump float;
2483			${DECLARATIONS}
2484
2485			vec4 get (in float arr[4]);
2486			void set (out float arr[4], vec4 val);
2487			void negate (inout float arr[4]);
2488			bool test (in float arr[4], vec4 ref);
2489			bool isEqual (in float a[4], in float b[4]);
2490
2491			float func (in float a[4], in float b[4])
2492			{
2493				a[0] = 2.123;
2494				a[2] = -4.123;
2495				return isEqual(a, b) ? 1.0 : -1.0;
2496			}
2497
2498			float arr[4];
2499
2500			void main()
2501			{
2502				set(arr, in0);
2503				out0 = in0 * func(arr, arr);
2504				${OUTPUT}
2505			}
2506
2507			float absDiff (vec4 a, vec4 b) { vec4 d = abs(a - b); return max(max(d.x, d.y), max(d.z, d.w)); }
2508			vec4 get (in float arr[4]) { return vec4(arr[0], arr[1], arr[2], arr[3]); }
2509			void set (out float arr[4], vec4 val) { arr[0] = val.x; arr[1] = val.y; arr[2] = val.z; arr[3] = val.w; }
2510			void negate (inout float arr[4]) { set(arr, -get(arr)); }
2511			bool test (in float arr[4], vec4 ref) { return (absDiff(get(arr), ref) < 0.1); }
2512			bool isEqual (in float a[4], in float b[4]) { return (absDiff(get(a), get(b)) < 0.1); }
2513		""
2514	end
2515
2516	case copy_local_inout_on_call
2517		version 300 es
2518		desc "Check that local 'in' arguments are copied on call and don't alias."
2519		values
2520		{
2521			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2522			output vec4 out0	= [ vec4(0.0, -1.0, -2.0, 4.0) | vec4(7.5, -12.125, 0.25, -16.0) ];
2523		}
2524
2525		both ""
2526			#version 300 es
2527			precision mediump float;
2528			${DECLARATIONS}
2529
2530			vec4 get (in float arr[4]);
2531			void set (out float arr[4], vec4 val);
2532			void negate (inout float arr[4]);
2533			bool test (in float arr[4], vec4 ref);
2534			bool isEqual (in float a[4], in float b[4]);
2535
2536			float func (inout float a[4], inout float b[4])
2537			{
2538				negate(a);
2539				return isEqual(a, b) ? 1.0 : -1.0;
2540			}
2541
2542			void main()
2543			{
2544				float arr[4];
2545				set(arr, in0);
2546				float m = func(arr, arr); // returns -1.0
2547				float n = float(test(arr, in0) || test(arr, -in0));
2548				out0 = in0 * m * n;
2549				${OUTPUT}
2550			}
2551
2552			float absDiff (vec4 a, vec4 b) { vec4 d = abs(a - b); return max(max(d.x, d.y), max(d.z, d.w)); }
2553			vec4 get (in float arr[4]) { return vec4(arr[0], arr[1], arr[2], arr[3]); }
2554			void set (out float arr[4], vec4 val) { arr[0] = val.x; arr[1] = val.y; arr[2] = val.z; arr[3] = val.w; }
2555			void negate (inout float arr[4]) { set(arr, -get(arr)); }
2556			bool test (in float arr[4], vec4 ref) { return (absDiff(get(arr), ref) < 0.1); }
2557			bool isEqual (in float a[4], in float b[4]) { return (absDiff(get(a), get(b)) < 0.1); }
2558		""
2559	end
2560
2561	case copy_global_inout_on_call
2562		version 300 es
2563		desc "Check that global 'in' arguments are copied on call and don't alias."
2564		values
2565		{
2566			input vec4 in0		= [ vec4(0.0, 1.0, 2.0, -4.0) | vec4(-7.5, 12.125, -0.25, 16.0) ];
2567			output vec4 out0	= [ vec4(0.0, -1.0, -2.0, 4.0) | vec4(7.5, -12.125, 0.25, -16.0) ];
2568		}
2569
2570		both ""
2571			#version 300 es
2572			precision mediump float;
2573			${DECLARATIONS}
2574
2575			vec4 get (in float arr[4]);
2576			void set (out float arr[4], vec4 val);
2577			void negate (inout float arr[4]);
2578			bool test (in float arr[4], vec4 ref);
2579			bool isEqual (in float a[4], in float b[4]);
2580
2581			float func (in float a[4], in float b[4])
2582			{
2583				negate(a);
2584				return isEqual(a, b) ? 1.0 : -1.0;
2585			}
2586
2587			float arr[4];
2588
2589			void main()
2590			{
2591				set(arr, in0);
2592				float m = func(arr, arr); // returns -1.0
2593				float n = float(test(arr, in0) || test(arr, -in0));
2594				out0 = in0 * m * n;
2595				${OUTPUT}
2596			}
2597
2598			float absDiff (vec4 a, vec4 b) { vec4 d = abs(a - b); return max(max(d.x, d.y), max(d.z, d.w)); }
2599			vec4 get (in float arr[4]) { return vec4(arr[0], arr[1], arr[2], arr[3]); }
2600			void set (out float arr[4], vec4 val) { arr[0] = val.x; arr[1] = val.y; arr[2] = val.z; arr[3] = val.w; }
2601			void negate (inout float arr[4]) { set(arr, -get(arr)); }
2602			bool test (in float arr[4], vec4 ref) { return (absDiff(get(arr), ref) < 0.1); }
2603			bool isEqual (in float a[4], in float b[4]) { return (absDiff(get(a), get(b)) < 0.1); }
2604		""
2605	end
2606
2607#			vec4 get (in float arr[4]);
2608#			void set (out float arr[4], vec4 val);
2609#			void negate (inout float arr[4]);
2610#			bool test (in float arr[4], vec4 ref);
2611#			bool isEqual (in float a[4], in float b[4]);
2612
2613#			float absDiff (vec4 a, vec4 b) { vec4 d = abs(a - b); return max(max(d.x, d.y), max(d.z, d.w)); }
2614#			vec4 get (in float arr[4]) { return vec4(arr[0], arr[1], arr[2], arr[3]); }
2615#			void set (out float arr[4], vec4 val) { arr[0] = val.x; arr[1] = val.y; arr[2] = val.z; arr[3] = val.w; }
2616#			void negate (inout float arr[4]) { set(arr, -get(arr)); }
2617#			bool test (in float arr[4], vec4 ref) { return (absDiff(get(arr), ref) < 0.1); }
2618#			bool isEqual (in float a[4], in float b[4]) { return (absDiff(get(a), get(b)) < 0.1); }
2619
2620end # array_arguments
2621
2622#group qualifiers "Function Parameter Qualifiers"
2623#
2624#end # qualifiers
2625
2626group control_flow "Control Flow In Functions"
2627
2628	case simple_return
2629		version 300 es
2630		values
2631		{
2632			input float in0		= [ -0.5 | 1.5 ];
2633			output float out0	= [ 0.5 | -1.5 ];
2634		}
2635
2636		both ""
2637			#version 300 es
2638			precision mediump float;
2639			${DECLARATIONS}
2640
2641			float func (float a)
2642			{
2643				return -a;
2644				a = a * -1.0;
2645				return 1.0;
2646			}
2647
2648			void main()
2649			{
2650				${SETUP}
2651				out0 = func(in0);
2652				${OUTPUT}
2653			}
2654		""
2655	end
2656
2657	case return_in_if
2658		version 300 es
2659		values
2660		{
2661			input float in0		= [ -0.5 | 1.5 ];
2662			output float out0	= [ 0.5 | -1.5 ];
2663		}
2664
2665		both ""
2666			#version 300 es
2667			precision mediump float;
2668			${DECLARATIONS}
2669
2670			float func (float a)
2671			{
2672				if (a != 0.0)
2673					return -a;
2674				return 1.0;
2675			}
2676
2677			void main()
2678			{
2679				${SETUP}
2680				out0 = func(in0);
2681				${OUTPUT}
2682			}
2683		""
2684	end
2685
2686	case return_in_else
2687		version 300 es
2688		values
2689		{
2690			input float in0		= [ -0.5 | 1.5 ];
2691			output float out0	= [ 0.5 | -1.5 ];
2692		}
2693
2694		both ""
2695			#version 300 es
2696			precision mediump float;
2697			${DECLARATIONS}
2698
2699			float func (float a)
2700			{
2701				if (a == 0.0)
2702					return 1.0;
2703				else
2704					return -a;
2705				return 1.0;
2706			}
2707
2708			void main()
2709			{
2710				${SETUP}
2711				out0 = func(in0);
2712				${OUTPUT}
2713			}
2714		""
2715	end
2716
2717	case return_in_loop
2718		version 300 es
2719		values
2720		{
2721			input float in0		= [ -0.5 | 1.5 ];
2722			output float out0	= [ 0.5 | -1.5 ];
2723		}
2724
2725		both ""
2726			#version 300 es
2727			precision mediump float;
2728			${DECLARATIONS}
2729
2730			float func (float a)
2731			{
2732				while (a < 100.0)
2733					return -a;
2734				return 1.0;
2735			}
2736
2737			void main()
2738			{
2739				${SETUP}
2740				out0 = func(in0);
2741				${OUTPUT}
2742			}
2743		""
2744	end
2745
2746	case return_in_loop_if
2747		version 300 es
2748		values
2749		{
2750			input float in0		= [ -0.5 | 1.5 ];
2751			output float out0	= [ 0.5 | -1.5 ];
2752		}
2753
2754		both ""
2755			#version 300 es
2756			precision mediump float;
2757			${DECLARATIONS}
2758
2759			float func (float a)
2760			{
2761				while (a < 100.0)
2762				{
2763					a = -a;
2764					if (a != 0.0)
2765						return a;
2766					else
2767						return -1.0;
2768				}
2769				return 1.0;
2770			}
2771
2772			void main()
2773			{
2774				${SETUP}
2775				out0 = func(in0);
2776				${OUTPUT}
2777			}
2778		""
2779	end
2780
2781	case return_after_loop
2782		version 300 es
2783		values
2784		{
2785			input float in0		= [ -0.5 | 1.5 ];
2786			output float out0	= [ 0.5 | -1.5 ];
2787		}
2788
2789		both ""
2790			#version 300 es
2791			precision mediump float;
2792			${DECLARATIONS}
2793
2794			float func (float a)
2795			{
2796				for (int i = 0; i < 5; i++)
2797					a = -a;
2798				return a;
2799			}
2800
2801			void main()
2802			{
2803				${SETUP}
2804				out0 = func(in0);
2805				${OUTPUT}
2806			}
2807		""
2808	end
2809
2810	case return_after_break
2811		version 300 es
2812		values
2813		{
2814			input float in0		= [ -0.5 | 1.5 ];
2815			output float out0	= [ 0.5 | -1.5 ];
2816		}
2817
2818		both ""
2819			#version 300 es
2820			precision mediump float;
2821			${DECLARATIONS}
2822
2823			float func (float a)
2824			{
2825				for (int i = 0; i < 6; i++)
2826				{
2827					a = -a;
2828					if (i == 4)
2829						break;
2830				}
2831				return a;
2832			}
2833
2834			void main()
2835			{
2836				${SETUP}
2837				out0 = func(in0);
2838				${OUTPUT}
2839			}
2840		""
2841	end
2842
2843	case return_after_continue
2844		version 300 es
2845		values
2846		{
2847			input float in0		= [ -0.5 | 1.5 ];
2848			output float out0	= [ 0.5 | -1.5 ];
2849		}
2850
2851		both ""
2852			#version 300 es
2853			precision mediump float;
2854			${DECLARATIONS}
2855
2856			float func (float a)
2857			{
2858				for (int i = 0; i < 6; i++)
2859				{
2860					if (i == 4)
2861						continue;
2862					a = -a;
2863				}
2864				return a;
2865			}
2866
2867			void main()
2868			{
2869				${SETUP}
2870				out0 = func(in0);
2871				${OUTPUT}
2872			}
2873		""
2874	end
2875
2876	case return_in_nested_loop
2877		version 300 es
2878		values
2879		{
2880			input float in0		= [ -0.5 | 1.5 ];
2881			output float out0	= [ 0.5 | -1.5 ];
2882		}
2883
2884		both ""
2885			#version 300 es
2886			precision mediump float;
2887			${DECLARATIONS}
2888
2889			float func (float a)
2890			{
2891				for (int i = 0; i < 6; i++)
2892				{
2893					a = -a;
2894					for (int j = 0; j < 4; j++)
2895					{
2896						a = -a;
2897						if (i == 1)
2898							return a;
2899					}
2900					if (i == 4)
2901						return 1.0;
2902				}
2903				return 1.0;
2904			}
2905
2906			void main()
2907			{
2908				${SETUP}
2909				out0 = func(in0);
2910				${OUTPUT}
2911			}
2912		""
2913	end
2914
2915	case return_after_loop_sequence
2916		version 300 es
2917		values
2918		{
2919			input float in0		= [ -0.5 | 1.5 ];
2920			output float out0	= [ 0.5 | -1.5 ];
2921		}
2922
2923		both ""
2924			#version 300 es
2925			precision mediump float;
2926			${DECLARATIONS}
2927
2928			float func (float a)
2929			{
2930				int i;
2931				for (i = 0; i < 6; i++) // negate a
2932				{
2933					a = -a;
2934					if (i == 4)
2935						a = -a;
2936				}
2937
2938				for (; i < 10; i++) // keep a
2939				{
2940					if (i == 8)
2941						continue;
2942					else if (i == 9)
2943						break;
2944					a = -a;
2945				}
2946
2947				return a;
2948			}
2949
2950			void main()
2951			{
2952				${SETUP}
2953				out0 = func(in0);
2954				${OUTPUT}
2955			}
2956		""
2957	end
2958
2959	case mixed_return_break_continue
2960		version 300 es
2961		values
2962		{
2963			input float in0		= [ -0.5 | 1.5 ];
2964			output float out0	= [ 0.5 | -1.5 ];
2965		}
2966
2967		both ""
2968			#version 300 es
2969			precision mediump float;
2970			${DECLARATIONS}
2971
2972			float func (float a)
2973			{
2974				int i;
2975				for (i = 0; i < 6; i++)
2976				{
2977					if (i == 0)
2978						continue;
2979					else if (i == 1)
2980					{
2981					}
2982					else if (i == 3)
2983						break;
2984					else
2985						return a;
2986					a = -a;
2987				}
2988
2989				return 1.0;
2990			}
2991
2992			void main()
2993			{
2994				${SETUP}
2995				out0 = func(in0);
2996				${OUTPUT}
2997			}
2998		""
2999	end
3000
3001end # control_flow
3002
3003group misc "Miscellaneous"
3004
3005	case multi_arg_float
3006		version 300 es
3007		values
3008		{
3009			input vec4 in0		= [ vec4(0.0, 1.0, -2.0, 0.5) | vec4(2.0, 2.5, 4.0, -7.0) ];
3010			output float out0	= [ 0.5 | -1.5 ]; # -sum(in0)
3011		}
3012
3013		both ""
3014			#version 300 es
3015			precision mediump float;
3016			${DECLARATIONS}
3017
3018			float sum(vec4 v) { return (v.x + v.y + v.z + v.w); }
3019
3020			float func (float a, vec3 b, vec2 c, vec2 d, vec4 e)
3021			{
3022				return -sum(vec4(a, b) + vec4(c, d)) + sum(e);
3023			}
3024
3025			void main()
3026			{
3027				${SETUP}
3028				out0 = func(in0.y, in0.xzw, in0.wz, in0.yx, in0);
3029				${OUTPUT}
3030			}
3031		""
3032	end
3033
3034	case multi_arg_int
3035		version 300 es
3036		values
3037		{
3038			input ivec4 in0		= [ ivec4(-1, 0, 2, 2) | ivec4(1, 4, -8, 2) ];
3039			output int out0		= [ -3 | 1 ];
3040		}
3041
3042		both ""
3043			#version 300 es
3044			precision mediump float;
3045			precision mediump int;
3046			${DECLARATIONS}
3047
3048			int sum(ivec4 v) { return (v.x + v.y + v.z + v.w); }
3049
3050			int func (int a, ivec3 b, ivec2 c, ivec2 d, ivec4 e)
3051			{
3052				return -sum(ivec4(a, b) + ivec4(c, d)) + sum(e);
3053			}
3054
3055			void main()
3056			{
3057				${SETUP}
3058				out0 = func(in0.y, in0.xzw, in0.wz, in0.yx, in0);
3059				${OUTPUT}
3060			}
3061		""
3062	end
3063
3064	case argument_eval_order_1
3065		version 300 es
3066		values
3067		{
3068			input int in0	= [  0 | 1 | 3 | 5 ];
3069			output int out0	= [ -1 | 5 | 11 | 17 ];
3070		}
3071
3072		both ""
3073			#version 300 es
3074			precision highp float;
3075			${DECLARATIONS}
3076
3077			int func (float a, int b, bool c, int d)
3078			{
3079				if (c)
3080					return b + int(a) + d;
3081				else
3082					return -1;
3083			}
3084
3085			void main ()
3086			{
3087				${SETUP}
3088				float v0 = float(in0);
3089				int v1 = in0;
3090				out0 = func((v0 += 1.0), v1++, (v0 > 1.5), v1);
3091				${OUTPUT}
3092			}
3093		""
3094	end
3095
3096	case argument_eval_order_2
3097		version 300 es
3098		values
3099		{
3100			input int in0	= [ 0 | -1 | 3 | 5 ];
3101			output int out0	= [ 3 | -1 | 9 | 13 ];
3102		}
3103
3104		both ""
3105			#version 300 es
3106			precision highp float;
3107			${DECLARATIONS}
3108
3109			int g;
3110
3111			int modG (int v)
3112			{
3113				g += v;
3114				return v;
3115			}
3116
3117			int func (float a, int b, bool c, int d)
3118			{
3119				if (c)
3120					return b + int(a) + d;
3121				else
3122					return -1;
3123			}
3124
3125			void main ()
3126			{
3127				${SETUP}
3128				out0 = func(float(g = in0), modG(2), --g > 0, g);
3129				${OUTPUT}
3130			}
3131		""
3132	end
3133
3134end # misc
3135
3136group invalid "Invalid Functions"
3137	case break_in_body
3138		version 300 es
3139		expect compile_fail
3140		both ""
3141			#version 300 es
3142			precision mediump float;
3143			${DECLARATIONS}
3144
3145			void func ()
3146			{
3147				break;
3148			}
3149
3150			void main ()
3151			{
3152				${POSITION_FRAG_COLOR} = vec4(1.0);
3153			}
3154		""
3155	end
3156
3157	case continue_in_body
3158		version 300 es
3159		expect compile_fail
3160		both ""
3161			#version 300 es
3162			precision mediump float;
3163			${DECLARATIONS}
3164
3165			void func ()
3166			{
3167				continue;
3168			}
3169
3170			void main ()
3171			{
3172				${POSITION_FRAG_COLOR} = vec4(1.0);
3173			}
3174		""
3175	end
3176
3177	case return_value_from_void_function
3178		version 300 es
3179		expect compile_fail
3180		both ""
3181			#version 300 es
3182			precision mediump float;
3183			${DECLARATIONS}
3184
3185			void func ()
3186			{
3187				return 1.0;
3188			}
3189
3190			void main ()
3191			{
3192				${POSITION_FRAG_COLOR} = vec4(1.0);
3193			}
3194		""
3195	end
3196
3197	case extra_arguments
3198		version 300 es
3199		expect compile_fail
3200		both ""
3201			#version 300 es
3202			precision mediump float;
3203			${DECLARATIONS}
3204
3205			void func (float f)
3206			{
3207			}
3208
3209			void main ()
3210			{
3211				func(1.0, 2.0);
3212				${POSITION_FRAG_COLOR} = vec4(1.0);
3213			}
3214		""
3215	end
3216
3217	case missing_arguments
3218		version 300 es
3219		expect compile_fail
3220		both ""
3221			#version 300 es
3222			precision mediump float;
3223			${DECLARATIONS}
3224
3225			void func (float f)
3226			{
3227			}
3228
3229			void main ()
3230			{
3231				func();
3232				${POSITION_FRAG_COLOR} = vec4(1.0);
3233			}
3234		""
3235	end
3236
3237	case missing_argument_type
3238		version 300 es
3239		expect compile_fail
3240		both ""
3241			#version 300 es
3242			precision mediump float;
3243			${DECLARATIONS}
3244
3245			void func (in f)
3246			{
3247			}
3248
3249			void main ()
3250			{
3251				${POSITION_FRAG_COLOR} = vec4(1.0);
3252			}
3253		""
3254	end
3255
3256	case argument_basetype_mismatch
3257		version 300 es
3258		expect compile_fail
3259		both ""
3260			#version 300 es
3261			precision mediump float;
3262			precision mediump int;
3263			${DECLARATIONS}
3264
3265			void func (float f)
3266			{
3267			}
3268
3269			void main ()
3270			{
3271				func(2);
3272				${POSITION_FRAG_COLOR} = vec4(1.0);
3273			}
3274		""
3275	end
3276
3277	case argument_scalar_vector_mismatch
3278		version 300 es
3279		expect compile_fail
3280		both ""
3281			#version 300 es
3282			precision mediump float;
3283			${DECLARATIONS}
3284
3285			void func (vec2 f)
3286			{
3287			}
3288
3289			void main ()
3290			{
3291				func(2.0);
3292				${POSITION_FRAG_COLOR} = vec4(1.0);
3293			}
3294		""
3295	end
3296
3297	case argument_vector_size_mismatch
3298		version 300 es
3299		expect compile_fail
3300		both ""
3301			#version 300 es
3302			precision mediump float;
3303			${DECLARATIONS}
3304
3305			void func (vec3 f)
3306			{
3307			}
3308
3309			void main ()
3310			{
3311				func(vec2(2.0));
3312				${POSITION_FRAG_COLOR} = vec4(1.0);
3313			}
3314		""
3315	end
3316
3317	case duplicate_function
3318		version 300 es
3319		expect compile_fail
3320		both ""
3321			#version 300 es
3322			precision mediump float;
3323			${DECLARATIONS}
3324
3325			void func (vec3 f);
3326
3327			void func (vec3 f)
3328			{
3329			}
3330
3331			void func (vec3 f)
3332			{
3333			}
3334
3335			void main ()
3336			{
3337				${POSITION_FRAG_COLOR} = vec4(1.0);
3338			}
3339		""
3340	end
3341
3342	case prototype_mismatch_return_type
3343		version 300 es
3344		expect compile_fail
3345		both ""
3346			#version 300 es
3347			precision mediump float;
3348			${DECLARATIONS}
3349
3350			void func (vec3 f);
3351
3352			void main ()
3353			{
3354				${POSITION_FRAG_COLOR} = vec4(1.0);
3355			}
3356
3357			float func (vec3 f)
3358			{
3359				return f.x;
3360			}
3361		""
3362	end
3363
3364	case prototype_unspecified_array_size
3365		version 300 es
3366		expect compile_fail
3367		both ""
3368			#version 300 es
3369			precision mediump float;
3370			${DECLARATIONS}
3371
3372			void func (vec3 f[]);
3373
3374			void main ()
3375			{
3376				${POSITION_FRAG_COLOR} = vec4(1.0);
3377			}
3378		""
3379	end
3380
3381	case call_mismatch_argument_array_size
3382		version 300 es
3383		expect compile_fail
3384		both ""
3385			#version 300 es
3386			precision mediump float;
3387			${DECLARATIONS}
3388
3389			void func (vec3 f[3]);
3390			void func (vec3 f[3])
3391			{
3392			}
3393
3394			void main ()
3395			{
3396				vec3 array[4];
3397				func(array);
3398				${POSITION_FRAG_COLOR} = vec4(1.0);
3399			}
3400		""
3401	end
3402
3403	case prototype_mismatch_argument_const
3404		version 300 es
3405		expect compile_fail
3406		both ""
3407			#version 300 es
3408			precision mediump float;
3409			${DECLARATIONS}
3410
3411			void func (vec3 f);
3412			void func (const vec3 f)
3413			{
3414			}
3415
3416			void main ()
3417			{
3418				${POSITION_FRAG_COLOR} = vec4(1.0);
3419			}
3420		""
3421	end
3422
3423	case prototype_mismatch_argument_array_const
3424		version 300 es
3425		expect compile_fail
3426		both ""
3427			#version 300 es
3428			precision mediump float;
3429			${DECLARATIONS}
3430
3431			void func (vec3 f[3]);
3432			void func (const vec3 f[3])
3433			{
3434			}
3435
3436			void main ()
3437			{
3438				${POSITION_FRAG_COLOR} = vec4(1.0);
3439			}
3440		""
3441	end
3442
3443	case prototype_mismatch_array_inout
3444		version 300 es
3445		expect compile_fail
3446		both ""
3447			#version 300 es
3448			precision mediump float;
3449			${DECLARATIONS}
3450
3451			void func (out vec3 f);
3452			void func (inout vec3 f)
3453			{
3454			}
3455
3456			void main ()
3457			{
3458				${POSITION_FRAG_COLOR} = vec4(1.0);
3459			}
3460		""
3461	end
3462
3463	case missing_return_type
3464		version 300 es
3465		expect compile_fail
3466		both ""
3467			#version 300 es
3468			precision mediump float;
3469			${DECLARATIONS}
3470
3471			func (float f);
3472			func (inout vec3 f[3])
3473			{
3474			}
3475
3476			void main ()
3477			{
3478				${POSITION_FRAG_COLOR} = vec4(1.0);
3479			}
3480		""
3481	end
3482
3483	case call_before_definition
3484		version 300 es
3485		expect compile_fail
3486		both ""
3487			#version 300 es
3488			precision mediump float;
3489			${DECLARATIONS}
3490
3491			void main ()
3492			{
3493				func(1.0);
3494				${POSITION_FRAG_COLOR} = vec4(1.0);
3495			}
3496
3497			void func (float f)
3498			{
3499			}
3500
3501		""
3502	end
3503
3504	case argument_precision_overload
3505		version 300 es
3506		expect compile_fail
3507		both ""
3508			#version 300 es
3509			precision mediump float;
3510			${DECLARATIONS}
3511
3512			float func (lowp float f)
3513			{
3514				return f;
3515			}
3516
3517			float func (mediump float f)
3518			{
3519				return f;
3520			}
3521
3522			void main ()
3523			{
3524				${POSITION_FRAG_COLOR} = vec4(1.0);
3525			}
3526		""
3527	end
3528
3529	case argument_in_out_overload
3530		version 300 es
3531		expect compile_fail
3532		both ""
3533			#version 300 es
3534			precision mediump float;
3535			${DECLARATIONS}
3536
3537			void func (in float f)
3538			{
3539			}
3540
3541			void func (out float f)
3542			{
3543				f = 1.0;
3544			}
3545
3546			void main ()
3547			{
3548				${POSITION_FRAG_COLOR} = vec4(1.0);
3549			}
3550		""
3551	end
3552
3553	case argument_in_inout_overload
3554		version 300 es
3555		expect compile_fail
3556		both ""
3557			#version 300 es
3558			precision mediump float;
3559			${DECLARATIONS}
3560
3561			void func (in float f)
3562			{
3563			}
3564
3565			void func (inout float f)
3566			{
3567				f = -f;
3568			}
3569
3570			void main ()
3571			{
3572				${POSITION_FRAG_COLOR} = vec4(1.0);
3573			}
3574		""
3575	end
3576
3577	case argument_out_inout_overload
3578		version 300 es
3579		expect compile_fail
3580		both ""
3581			#version 300 es
3582			precision mediump float;
3583			${DECLARATIONS}
3584
3585			void func (out float f)
3586			{
3587				f = -1.0;
3588			}
3589
3590			void func (inout float f)
3591			{
3592				f = -f;
3593			}
3594
3595			void main ()
3596			{
3597				${POSITION_FRAG_COLOR} = vec4(1.0);
3598			}
3599		""
3600	end
3601
3602	case return_type_overload
3603		version 300 es
3604		expect compile_fail
3605		both ""
3606			#version 300 es
3607			precision mediump float;
3608			${DECLARATIONS}
3609
3610			float func (float f)
3611			{
3612				return f;
3613			}
3614
3615			int func (float f)
3616			{
3617				return int(f);
3618			}
3619
3620			void main ()
3621			{
3622				${POSITION_FRAG_COLOR} = vec4(1.0);
3623			}
3624		""
3625	end
3626
3627	case return_type_precision_overload
3628		version 300 es
3629		expect compile_fail
3630		both ""
3631			#version 300 es
3632			precision mediump float;
3633			${DECLARATIONS}
3634
3635			lowp float func (float f)
3636			{
3637				return f;
3638			}
3639
3640			mediump float func (float f)
3641			{
3642				return f;
3643			}
3644
3645			void main ()
3646			{
3647				${POSITION_FRAG_COLOR} = vec4(1.0);
3648			}
3649		""
3650	end
3651
3652	case return_type_const_overload
3653		version 300 es
3654		expect compile_fail
3655		both ""
3656			#version 300 es
3657			precision mediump float;
3658			${DECLARATIONS}
3659
3660			float func (float f)
3661			{
3662				return f;
3663			}
3664
3665			const float func (float f)
3666			{
3667				return f;
3668			}
3669
3670			void main ()
3671			{
3672				${POSITION_FRAG_COLOR} = vec4(1.0);
3673			}
3674		""
3675	end
3676
3677	case return_without_value
3678		version 300 es
3679		expect compile_fail
3680		both ""
3681			#version 300 es
3682			precision mediump float;
3683			${DECLARATIONS}
3684
3685			float func (float f)
3686			{
3687				return;
3688				return 1.0;
3689			}
3690
3691			void main ()
3692			{
3693				${POSITION_FRAG_COLOR} = vec4(1.0);
3694			}
3695		""
3696	end
3697
3698	case local_function_prototype
3699		version 300 es
3700		expect compile_fail
3701		both ""
3702			#version 300 es
3703			precision mediump float;
3704			${DECLARATIONS}
3705
3706			void main ()
3707			{
3708				float func (float f);
3709
3710				${POSITION_FRAG_COLOR} = vec4(1.0);
3711			}
3712		""
3713	end
3714
3715	case local_function_definition
3716		version 300 es
3717		expect compile_fail
3718		both ""
3719			#version 300 es
3720			precision mediump float;
3721			${DECLARATIONS}
3722
3723			void main ()
3724			{
3725				float func (float f)
3726				{
3727					return 1.0;
3728				}
3729
3730				${POSITION_FRAG_COLOR} = vec4(1.0);
3731			}
3732		""
3733	end
3734
3735	case name_type_conflict
3736		version 300 es
3737		expect compile_fail
3738		both ""
3739			#version 300 es
3740			precision mediump float;
3741			${DECLARATIONS}
3742
3743			struct foo { float a; }
3744
3745			float foo (float f)
3746			{
3747				return 1.0;
3748			}
3749
3750			void main ()
3751			{
3752				${POSITION_FRAG_COLOR} = vec4(1.0);
3753			}
3754		""
3755	end
3756
3757	case const_overload
3758		version 300 es
3759		expect compile_fail
3760		both ""
3761			#version 300 es
3762			precision mediump float;
3763			${DECLARATIONS}
3764
3765			void func (vec3 f)
3766			{
3767			}
3768
3769			void func (const vec3 f)
3770			{
3771			}
3772
3773			void main ()
3774			{
3775				${POSITION_FRAG_COLOR} = vec4(1.0);
3776			}
3777		""
3778	end
3779
3780	case uniform_local
3781		version 300 es
3782		expect compile_fail
3783		both ""
3784			#version 300 es
3785			precision mediump float;
3786			${DECLARATIONS}
3787
3788			void func (vec3 f)
3789			{
3790				uniform float u;
3791			}
3792
3793			void main ()
3794			{
3795				${POSITION_FRAG_COLOR} = vec4(1.0);
3796			}
3797		""
3798	end
3799
3800	case in_local
3801		version 300 es
3802		expect compile_fail
3803		both ""
3804			#version 300 es
3805			precision mediump float;
3806			${DECLARATIONS}
3807
3808			void func (vec3 f)
3809			{
3810				in float v;
3811			}
3812
3813			void main ()
3814			{
3815				${POSITION_FRAG_COLOR} = vec4(1.0);
3816			}
3817		""
3818	end
3819
3820	case out_local
3821		version 300 es
3822		expect compile_fail
3823		both ""
3824			#version 300 es
3825			precision mediump float;
3826			${DECLARATIONS}
3827
3828			void func (vec3 f)
3829			{
3830				in float a;
3831			}
3832
3833			void main ()
3834			{
3835				${POSITION_FRAG_COLOR} = vec4(1.0);
3836			}
3837		""
3838	end
3839
3840	case inout_local
3841		version 300 es
3842		expect compile_fail
3843		both ""
3844			#version 300 es
3845			precision mediump float;
3846			${DECLARATIONS}
3847
3848			void func (vec3 f)
3849			{
3850				inout float a;
3851			}
3852
3853			void main ()
3854			{
3855				${POSITION_FRAG_COLOR} = vec4(1.0);
3856			}
3857		""
3858	end
3859
3860	case uniform_argument
3861		version 300 es
3862		expect compile_fail
3863		both ""
3864			#version 300 es
3865			precision mediump float;
3866			${DECLARATIONS}
3867
3868			void func (uniform vec3 f)
3869			{
3870			}
3871
3872			void main ()
3873			{
3874				${POSITION_FRAG_COLOR} = vec4(1.0);
3875			}
3876		""
3877	end
3878
3879	case uniform_return_type
3880		version 300 es
3881		expect compile_fail
3882		both ""
3883			#version 300 es
3884			precision mediump float;
3885			${DECLARATIONS}
3886
3887			uniform float func (vec3 f)
3888			{
3889				return f.x;
3890			}
3891
3892			void main ()
3893			{
3894				${POSITION_FRAG_COLOR} = vec4(1.0);
3895			}
3896		""
3897	end
3898
3899	case in_return_type
3900		version 300 es
3901		expect compile_fail
3902		both ""
3903			#version 300 es
3904			precision mediump float;
3905			${DECLARATIONS}
3906
3907			in float func (vec3 f)
3908			{
3909				return f.x;
3910			}
3911
3912			void main ()
3913			{
3914				${POSITION_FRAG_COLOR} = vec4(func(vec3(1.0)));
3915			}
3916		""
3917	end
3918
3919	case out_return_type
3920		version 300 es
3921		expect compile_fail
3922		both ""
3923			#version 300 es
3924			precision mediump float;
3925			${DECLARATIONS}
3926
3927			out float func (vec3 f)
3928			{
3929				return f.x;
3930			}
3931
3932			void main ()
3933			{
3934				${POSITION_FRAG_COLOR} = vec4(func(vec3(1.0)));
3935			}
3936		""
3937	end
3938
3939	case inout_return_type
3940		version 300 es
3941		expect compile_fail
3942		both ""
3943			#version 300 es
3944			precision mediump float;
3945			${DECLARATIONS}
3946
3947			inout float func (vec3 f)
3948			{
3949				return f.x;
3950			}
3951
3952			void main ()
3953			{
3954				${POSITION_FRAG_COLOR} = vec4(func(vec3(1.0)));
3955			}
3956		""
3957	end
3958
3959	case main_invalid_return_type
3960		version 300 es
3961		expect compile_fail
3962		both ""
3963			#version 300 es
3964			precision mediump float;
3965			${DECLARATIONS}
3966
3967			float main ()
3968			{
3969				${POSITION_FRAG_COLOR} = vec4(1.0);
3970			}
3971		""
3972	end
3973
3974	case main_has_arguments
3975		version 300 es
3976		expect compile_fail
3977		both ""
3978			#version 300 es
3979			precision mediump float;
3980			${DECLARATIONS}
3981
3982			void main (float f)
3983			{
3984				${POSITION_FRAG_COLOR} = vec4(1.0);
3985			}
3986		""
3987	end
3988
3989	case main_missing_return_type
3990		version 300 es
3991		expect compile_fail
3992		both ""
3993			#version 300 es
3994			precision mediump float;
3995			${DECLARATIONS}
3996
3997			main ()
3998			{
3999				${POSITION_FRAG_COLOR} = vec4(1.0);
4000			}
4001		""
4002	end
4003
4004	case write_const_arg
4005		version 300 es
4006		expect compile_fail
4007		both ""
4008			#version 300 es
4009			precision mediump float;
4010			${DECLARATIONS}
4011
4012			float func (const float f)
4013			{
4014				f = 1.0;
4015			}
4016
4017			void main ()
4018			{
4019				${POSITION_FRAG_COLOR} = vec4(1.0);
4020			}
4021		""
4022	end
4023
4024	case write_const_array_arg
4025		version 300 es
4026		expect compile_fail
4027		both ""
4028			#version 300 es
4029			precision mediump float;
4030			${DECLARATIONS}
4031
4032			float func (const float f[3])
4033			{
4034				f[0] = 1.0;
4035			}
4036
4037			void main ()
4038			{
4039				${POSITION_FRAG_COLOR} = vec4(1.0);
4040			}
4041		""
4042	end
4043
4044	case use_const_arg_in_const_expr
4045		version 300 es
4046		expect compile_fail
4047		both ""
4048			#version 300 es
4049			precision mediump float;
4050			${DECLARATIONS}
4051
4052			float func (const int i)
4053			{
4054				const int z = i+1;
4055				return float(z);
4056			}
4057
4058			void main ()
4059			{
4060				${POSITION_FRAG_COLOR} = vec4(func(1));
4061			}
4062		""
4063	end
4064
4065	case use_const_arg_as_array_size
4066		version 300 es
4067		expect compile_fail
4068		both ""
4069			#version 300 es
4070			precision mediump float;
4071			${DECLARATIONS}
4072
4073			float func (const int i)
4074			{
4075				float f[i];
4076				f[0] = 1.0;
4077				return f[0];
4078			}
4079
4080			void main ()
4081			{
4082				${POSITION_FRAG_COLOR} = vec4(func(1));
4083			}
4084		""
4085	end
4086
4087	case overload_builtin_function
4088		version 300 es
4089		expect compile_fail
4090		both ""
4091			#version 300 es
4092			precision mediump float;
4093			${DECLARATIONS}
4094
4095			int sin (int x)
4096			{
4097				return int(sin(float(x)));
4098			}
4099
4100			void main ()
4101			{
4102				${POSITION_FRAG_COLOR} = vec4(sin(1));
4103			}
4104		""
4105	end
4106
4107	case redefine_builtin_function
4108		version 300 es
4109		expect compile_fail
4110		both ""
4111			#version 300 es
4112			precision mediump float;
4113			${DECLARATIONS}
4114
4115			float sin (float x)
4116			{
4117				return 0.0;
4118			}
4119
4120			void main ()
4121			{
4122				${POSITION_FRAG_COLOR} = vec4(sin(1.0));
4123			}
4124		""
4125	end
4126
4127	case basic_recursion
4128		version 300 es
4129		expect compile_fail
4130		both ""
4131			#version 300 es
4132			precision mediump float;
4133			${DECLARATIONS}
4134
4135			float fib (float x)
4136			{
4137				if (x <= 1.0)
4138					return x;
4139				else
4140					return fib(x-2.0) + fib(x-1.0);
4141			}
4142
4143			void main ()
4144			{
4145				${POSITION_FRAG_COLOR} = vec4(fib(5.0));
4146			}
4147		""
4148	end
4149
4150	case simple_tail_recursion
4151		version 300 es
4152		expect compile_fail
4153		both ""
4154			#version 300 es
4155			precision mediump float;
4156			${DECLARATIONS}
4157
4158			float rec (float x)
4159			{
4160				if (x <= 0.0)
4161					return 0.0;
4162				else
4163					return rec(x-1.0);
4164			}
4165
4166			void main ()
4167			{
4168				${POSITION_FRAG_COLOR} = vec4(rec(5.0));
4169			}
4170		""
4171	end
4172
4173	case dynamic_conditional_recursion
4174		version 300 es
4175		expect compile_fail
4176		both ""
4177			#version 300 es
4178			precision mediump float;
4179			${DECLARATIONS}
4180			uniform float ua;
4181			uniform float ub;
4182
4183			float funcA (float x);
4184			float funcB (float x);
4185
4186			float funcA (float x)
4187			{
4188				if (ub+x > 0.0)
4189					funcB(x*2.0);
4190				else
4191					return ub;
4192			}
4193
4194			float funcB (float x)
4195			{
4196				return sqrt(funcA(x));
4197			}
4198
4199			void main ()
4200			{
4201				${POSITION_FRAG_COLOR} = vec4(funcB(ua));
4202			}
4203		""
4204	end
4205
4206	case dynamic_loop_recursion
4207		version 300 es
4208		expect compile_fail
4209		both ""
4210			#version 300 es
4211			precision mediump float;
4212			${DECLARATIONS}
4213			uniform float ua;
4214			uniform float ub;
4215
4216			float funcA (float x);
4217			float funcB (float x);
4218
4219			float funcA (float x)
4220			{
4221				for (float z = 0.0; z < ub+x; z++)
4222				{
4223					if (z > 2.0)
4224						funcB(z*2.0);
4225					else
4226						return z;
4227				}
4228			}
4229
4230			float funcB (float x)
4231			{
4232				return sqrt(funcA(x));
4233			}
4234
4235			void main ()
4236			{
4237				${POSITION_FRAG_COLOR} = vec4(funcB(ua));
4238			}
4239		""
4240	end
4241
4242	case dynamic_switch_recursion
4243		version 300 es
4244		expect compile_fail
4245		both ""
4246			#version 300 es
4247			precision mediump float;
4248			${DECLARATIONS}
4249			uniform float ua;
4250			uniform mediump int ub;
4251
4252			float funcA (float x);
4253			float funcB (float x);
4254
4255			float funcA (float x)
4256			{
4257				switch (ub + int(x))
4258				{
4259					case 0: return ua-1.0;
4260					case 1: return ua;
4261					case 2: return funcB(x*2.0);
4262					default: return 0.0;
4263				}
4264			}
4265
4266			float funcB (float x)
4267			{
4268				return sqrt(funcA(x));
4269			}
4270
4271			void main ()
4272			{
4273				${POSITION_FRAG_COLOR} = vec4(funcB(ua));
4274			}
4275		""
4276	end
4277
4278	case modify_const_arg
4279		version 300 es
4280		expect compile_fail
4281		both ""
4282			#version 300 es
4283			precision mediump float;
4284			precision mediump int;
4285			${DECLARATIONS}
4286
4287			int func (const int a)
4288			{
4289				a = -a;
4290				return 2 * a;
4291			}
4292
4293			void main()
4294			{
4295				${POSITION_FRAG_COLOR} = vec4(func(3));
4296			}
4297		""
4298	end
4299
4300	case init_const_local_from_const_arg
4301		version 300 es
4302		expect compile_fail
4303		both ""
4304			#version 300 es
4305			precision mediump float;
4306			precision mediump int;
4307			${DECLARATIONS}
4308
4309			int func (const int a)
4310			{
4311				const int b = -a;
4312				return 2 * b;
4313			}
4314
4315			void main()
4316			{
4317				${POSITION_FRAG_COLOR} = vec4(func(3));
4318			}
4319		""
4320	end
4321
4322	case array_size_from_const_arg
4323		version 300 es
4324		expect compile_fail
4325		both ""
4326			#version 300 es
4327			precision mediump float;
4328			precision mediump int;
4329			${DECLARATIONS}
4330
4331			int func (const int a)
4332			{
4333				int arr[a];
4334				arr[1] = 3;
4335				return arr[1];
4336			}
4337
4338			void main()
4339			{
4340				${POSITION_FRAG_COLOR} = vec4(func(3));
4341			}
4342		""
4343	end
4344
4345end # invalid
4346