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