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