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