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