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 defined_macro_defined_test 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 #define AAA defined 1679 1680 #if AAA AAA 1681 out0 = 1.0; 1682 #else 1683 out0 = 0.0; 1684 #endif 1685 ${OUTPUT} 1686 } 1687 "" 1688 end 1689 1690 case defined_macro_undef 1691 version 300 es 1692 values { output float out0 = 1.0; } 1693 both "" 1694 #version 300 es 1695 precision mediump float; 1696 ${DECLARATIONS} 1697 void main() 1698 { 1699 #define BBB 1 1700 #define AAA defined(BBB) 1701 #undef BBB 1702 1703 #if !AAA 1704 out0 = 1.0; 1705 #else 1706 out0 = 0.0; 1707 #endif 1708 ${OUTPUT} 1709 } 1710 "" 1711 end 1712 1713 case define_defined 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 #define CCC 1 1723 #define defined BBB 1724 #define AAA defined 1725 1726 #if AAA CCC 1727 out0 = 1.0; 1728 #else 1729 out0 = 0.0; 1730 #endif 1731 ${OUTPUT} 1732 } 1733 "" 1734 end 1735 1736 case define_defined_outside_if 1737 version 300 es 1738 values { output float out0 = 1.0; } 1739 both "" 1740 #version 300 es 1741 precision mediump float; 1742 ${DECLARATIONS} 1743 void main() 1744 { 1745 #define CCC - 0.5 1746 #define defined 0.5 1747 #define AAA defined 1748 out0 = 1.0 - (AAA CCC); 1749 ${OUTPUT} 1750 } 1751 "" 1752 end 1753 1754 case defined_invalid_before_all_macros_replaced 1755 version 300 es 1756 expect compile_fail 1757 values { output float out0 = 1.0; } 1758 both "" 1759 #version 300 es 1760 precision mediump float; 1761 ${DECLARATIONS} 1762 void main() 1763 { 1764 #define FOO 1 1765 #define OPEN defined( 1766 #define CLOSE FOO) 1767 1768 #if OPEN CLOSE 1769 out0 = 1.0; 1770 #else 1771 out0 = 0.0; 1772 #endif 1773 ${OUTPUT} 1774 } 1775 "" 1776 end 1777 1778 case basic_3 1779 version 300 es 1780 values { output float out0 = 1.0; } 1781 both "" 1782 #version 300 es 1783 precision mediump float; 1784 ${DECLARATIONS} 1785 void main() 1786 { 1787 #if 0 1788 out0 = -1.0; 1789 #elif 0 1790 out0 = -2.0; 1791 #elif 1 1792 out0 = 1.0; 1793 #else 1794 out0 = -3.0; 1795 #endif 1796 ${OUTPUT} 1797 } 1798 "" 1799 end 1800 1801 case basic_4 1802 version 300 es 1803 values { output float out0 = 1.0; } 1804 both "" 1805 #version 300 es 1806 precision mediump float; 1807 ${DECLARATIONS} 1808 void main() 1809 { 1810 #if 0 1811 out0 = -1.0; 1812 #elif 0 1813 out0 = -2.0; 1814 #else 1815 out0 = 1.0; 1816 #endif 1817 ${OUTPUT} 1818 } 1819 "" 1820 end 1821 1822 case basic_5 1823 version 300 es 1824 values { output float out0 = 1.0; } 1825 both "" 1826 #version 300 es 1827 precision mediump float; 1828 ${DECLARATIONS} 1829 void main() 1830 { 1831 #if 1 1832 out0 = 1.0; 1833 #elif 0 1834 out0 = -2.0; 1835 #else 1836 out0 = -1.0; 1837 #endif 1838 ${OUTPUT} 1839 } 1840 "" 1841 end 1842 1843 case unary_ops_1 1844 version 300 es 1845 values { output float out0 = 1.0; } 1846 both "" 1847 #version 300 es 1848 precision mediump float; 1849 ${DECLARATIONS} 1850 void main() 1851 { 1852 #if !((~2 >> 1) & 1) 1853 out0 = 1.0; 1854 #else 1855 out0 = -1.0; 1856 #endif 1857 ${OUTPUT} 1858 } 1859 "" 1860 end 1861 1862 case unary_ops_2 1863 version 300 es 1864 values { output float out0 = 1.0; } 1865 both "" 1866 #version 300 es 1867 precision mediump float; 1868 ${DECLARATIONS} 1869 void main() 1870 { 1871 #if !((~(- - - - - 1 + + + + + +1) >> 1) & 1) 1872 out0 = -1.0; 1873 #else 1874 out0 = 1.0; 1875 #endif 1876 ${OUTPUT} 1877 } 1878 "" 1879 end 1880 1881 end # conditional_inclusion 1882 1883 group invalid_ops "Invalid Operations Tests" 1884 1885 case invalid_op_1 1886 version 300 es 1887 expect compile_fail 1888 both "" 1889 #version 300 es 1890 precision mediump float; 1891 ${DECLARATIONS} 1892 void main() 1893 { 1894 #if !((~(+ ++1 - - - -1) >> 1) & 1) 1895 ${POSITION_FRAG_COLOR} = vec4(-1.0); 1896 #else 1897 ${POSITION_FRAG_COLOR} = vec4(1.0); 1898 #endif 1899 } 1900 "" 1901 end 1902 1903 case invalid_op_2 1904 version 300 es 1905 expect compile_fail 1906 both "" 1907 #version 300 es 1908 precision mediump float; 1909 ${DECLARATIONS} 1910 void main() 1911 { 1912 #if !((~(+ + +1 - -- -1) >> 1) & 1) 1913 ${POSITION_FRAG_COLOR} = vec4(-1.0); 1914 #else 1915 ${POSITION_FRAG_COLOR} = vec4(1.0); 1916 #endif 1917 } 1918 "" 1919 end 1920 1921 case invalid_defined_expected_identifier_1 1922 version 300 es 1923 expect compile_fail 1924 both "" 1925 #version 300 es 1926 precision mediump float; 1927 #define AAA 1 1928 1929 ${DECLARATIONS} 1930 void main() 1931 { 1932 #if defined 1933 ${POSITION_FRAG_COLOR} = vec4(1.0); 1934 #endif 1935 } 1936 "" 1937 end 1938 1939 case invalid_defined_expected_identifier_2 1940 version 300 es 1941 expect compile_fail 1942 both "" 1943 #version 300 es 1944 precision mediump float; 1945 #define AAA 1 1946 1947 ${DECLARATIONS} 1948 void main() 1949 { 1950 #if defined() 1951 ${POSITION_FRAG_COLOR} = vec4(1.0); 1952 #endif 1953 } 1954 "" 1955 end 1956 1957 case invalid_defined_expected_identifier_3 1958 version 300 es 1959 expect compile_fail 1960 both "" 1961 #version 300 es 1962 precision mediump float; 1963 #define AAA 1 1964 1965 ${DECLARATIONS} 1966 void main() 1967 { 1968 #if defined( 1969 ${POSITION_FRAG_COLOR} = vec4(1.0); 1970 #endif 1971 } 1972 "" 1973 end 1974 1975 case invalid_defined_expected_identifier_4 1976 version 300 es 1977 expect compile_fail 1978 both "" 1979 #version 300 es 1980 precision mediump float; 1981 #define AAA 1 1982 1983 ${DECLARATIONS} 1984 void main() 1985 { 1986 #if defined) 1987 ${POSITION_FRAG_COLOR} = vec4(1.0); 1988 #endif 1989 } 1990 "" 1991 end 1992 1993 case invalid_defined_expected_identifier_5 1994 version 300 es 1995 expect compile_fail 1996 both "" 1997 #version 300 es 1998 precision mediump float; 1999 #define AAA 1 2000 2001 ${DECLARATIONS} 2002 void main() 2003 { 2004 #if defined((AAA)) 2005 ${POSITION_FRAG_COLOR} = vec4(FUNC(1.0,2.0); 2006 #endif 2007 } 2008 "" 2009 end 2010 2011 case invalid_defined_expected_rparen 2012 version 300 es 2013 expect compile_fail 2014 both "" 2015 #version 300 es 2016 precision mediump float; 2017 #define AAA 1 2018 2019 ${DECLARATIONS} 2020 void main() 2021 { 2022 #if defined(AAA 2023 ${POSITION_FRAG_COLOR} = vec4(1.0); 2024 #endif 2025 } 2026 "" 2027 end 2028 2029 case defined_define 2030 version 300 es 2031 values { output float out0 = 1.0; } 2032 both "" 2033 #version 300 es 2034 precision mediump float; 2035 ${DECLARATIONS} 2036 #define define 1 2037 #define AAA 1.0 2038 2039 void main() 2040 { 2041 out0 = AAA; 2042 ${OUTPUT} 2043 } 2044 "" 2045 end 2046 2047 end # invalid_ops 2048 2049 group undefined_identifiers "Undefined Identifiers Tests" 2050 2051 case valid_undefined_identifier_1 2052 version 300 es 2053 values { output float out0 = 1.0; } 2054 both "" 2055 #version 300 es 2056 precision mediump float; 2057 ${DECLARATIONS} 2058 void main() 2059 { 2060 #if 1 || AAA 2061 out0 = 1.0; 2062 #else 2063 out0 = -1.0; 2064 #endif 2065 ${OUTPUT} 2066 } 2067 "" 2068 end 2069 2070 case valid_undefined_identifier_2 2071 version 300 es 2072 values { output float out0 = 1.0; } 2073 both "" 2074 #version 300 es 2075 precision mediump float; 2076 ${DECLARATIONS} 2077 void main() 2078 { 2079 #if 0 && AAA 2080 out0 = -1.0; 2081 #else 2082 out0 = 1.0; 2083 #endif 2084 ${OUTPUT} 2085 } 2086 "" 2087 end 2088 2089 case undefined_identifier_1 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 #if 1 - CCC + (-AAA || BBB) 2099 ${POSITION_FRAG_COLOR} = vec4(1.0); 2100 #else 2101 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2102 #endif 2103 } 2104 "" 2105 end 2106 2107 case undefined_identifier_2 2108 version 300 es 2109 expect compile_fail 2110 both "" 2111 #version 300 es 2112 precision mediump float; 2113 ${DECLARATIONS} 2114 void main() 2115 { 2116 #if !A 2117 ${POSITION_FRAG_COLOR} = vec4(1.0); 2118 #else 2119 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2120 #endif 2121 } 2122 "" 2123 end 2124 2125 case undefined_identifier_3 2126 version 300 es 2127 expect compile_fail 2128 both "" 2129 #version 300 es 2130 precision mediump float; 2131 ${DECLARATIONS} 2132 void main() 2133 { 2134 #if -A 2135 ${POSITION_FRAG_COLOR} = vec4(1.0); 2136 #else 2137 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2138 #endif 2139 } 2140 "" 2141 end 2142 2143 case undefined_identifier_4 2144 version 300 es 2145 expect compile_fail 2146 both "" 2147 #version 300 es 2148 precision mediump float; 2149 ${DECLARATIONS} 2150 void main() 2151 { 2152 #if ~A 2153 ${POSITION_FRAG_COLOR} = vec4(1.0); 2154 #else 2155 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2156 #endif 2157 } 2158 "" 2159 end 2160 2161 case undefined_identifier_5 2162 version 300 es 2163 expect compile_fail 2164 both "" 2165 #version 300 es 2166 precision mediump float; 2167 ${DECLARATIONS} 2168 void main() 2169 { 2170 #if A && B 2171 ${POSITION_FRAG_COLOR} = vec4(1.0); 2172 #else 2173 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2174 #endif 2175 } 2176 "" 2177 end 2178 2179 case undefined_identifier_6 2180 version 300 es 2181 expect compile_fail 2182 both "" 2183 #version 300 es 2184 precision mediump float; 2185 ${DECLARATIONS} 2186 void main() 2187 { 2188 #define A 1 2189 #if A && B 2190 ${POSITION_FRAG_COLOR} = vec4(1.0); 2191 #else 2192 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2193 #endif 2194 } 2195 "" 2196 end 2197 2198 case undefined_identifier_7 2199 version 300 es 2200 expect compile_fail 2201 both "" 2202 #version 300 es 2203 precision mediump float; 2204 ${DECLARATIONS} 2205 void main() 2206 { 2207 #define B 1 2208 #if A && B 2209 ${POSITION_FRAG_COLOR} = vec4(1.0); 2210 #else 2211 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2212 #endif 2213 } 2214 "" 2215 end 2216 2217 case undefined_identifier_8 2218 version 300 es 2219 expect compile_fail 2220 both "" 2221 #version 300 es 2222 precision mediump float; 2223 ${DECLARATIONS} 2224 void main() 2225 { 2226 #define B 1 2227 #define A 2 2228 #undef A 2229 #if A && B 2230 ${POSITION_FRAG_COLOR} = vec4(1.0); 2231 #else 2232 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2233 #endif 2234 } 2235 "" 2236 end 2237 2238 case undefined_identifier_9 2239 version 300 es 2240 expect compile_fail 2241 both "" 2242 #version 300 es 2243 precision mediump float; 2244 ${DECLARATIONS} 2245 void main() 2246 { 2247 #if A || B 2248 ${POSITION_FRAG_COLOR} = vec4(1.0); 2249 #else 2250 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2251 #endif 2252 } 2253 "" 2254 end 2255 2256 case undefined_identifier_10 2257 version 300 es 2258 expect compile_fail 2259 both "" 2260 #version 300 es 2261 precision mediump float; 2262 ${DECLARATIONS} 2263 void main() 2264 { 2265 #define A 0 2266 #if A || B 2267 ${POSITION_FRAG_COLOR} = vec4(1.0); 2268 #else 2269 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2270 #endif 2271 } 2272 "" 2273 end 2274 2275 case undefined_identifier_11 2276 version 300 es 2277 expect compile_fail 2278 both "" 2279 #version 300 es 2280 precision mediump float; 2281 ${DECLARATIONS} 2282 void main() 2283 { 2284 #define A 0 2285 #define B 2 2286 #undef B 2287 #if A || B 2288 ${POSITION_FRAG_COLOR} = vec4(1.0); 2289 #else 2290 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2291 #endif 2292 } 2293 "" 2294 end 2295 2296 case undefined_identifier_12 2297 version 300 es 2298 expect compile_fail 2299 both "" 2300 #version 300 es 2301 precision mediump float; 2302 ${DECLARATIONS} 2303 void main() 2304 { 2305 #define B 1 2306 #if A || B 2307 ${POSITION_FRAG_COLOR} = vec4(1.0); 2308 #else 2309 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2310 #endif 2311 } 2312 "" 2313 end 2314 2315 end # undefined_identifiers 2316 2317 group invalid_conditionals "Invalid Conditionals Tests" 2318 2319 case empty_if 2320 version 300 es 2321 expect compile_fail 2322 both "" 2323 #version 300 es 2324 precision mediump float; 2325 ${DECLARATIONS} 2326 void main() 2327 { 2328 #if 2329 ${POSITION_FRAG_COLOR} = vec4(1.0); 2330 } 2331 "" 2332 end 2333 2334 case empty_ifdef 2335 version 300 es 2336 expect compile_fail 2337 both "" 2338 #version 300 es 2339 precision mediump float; 2340 ${DECLARATIONS} 2341 void main() 2342 { 2343 #ifdef 2344 ${POSITION_FRAG_COLOR} = vec4(1.0); 2345 } 2346 "" 2347 end 2348 2349 case empty_ifndef 2350 version 300 es 2351 expect compile_fail 2352 both "" 2353 #version 300 es 2354 precision mediump float; 2355 ${DECLARATIONS} 2356 void main() 2357 { 2358 #ifndef 2359 ${POSITION_FRAG_COLOR} = vec4(1.0); 2360 } 2361 "" 2362 end 2363 2364 case invalid_ifdef 2365 version 300 es 2366 expect compile_fail 2367 both "" 2368 #version 300 es 2369 precision mediump float; 2370 ${DECLARATIONS} 2371 void main() 2372 { 2373 #ifdef 1 2374 ${POSITION_FRAG_COLOR} = vec4(1.0); 2375 #endif 2376 } 2377 "" 2378 end 2379 2380 case invalid_ifndef 2381 version 300 es 2382 expect compile_fail 2383 both "" 2384 #version 300 es 2385 precision mediump float; 2386 ${DECLARATIONS} 2387 void main() 2388 { 2389 #ifndef 1 2390 ${POSITION_FRAG_COLOR} = vec4(1.0); 2391 #endif 2392 } 2393 "" 2394 end 2395 2396 case empty_if_defined 2397 version 300 es 2398 expect compile_fail 2399 both "" 2400 #version 300 es 2401 precision mediump float; 2402 ${DECLARATIONS} 2403 void main() 2404 { 2405 #if defined 2406 ${POSITION_FRAG_COLOR} = vec4(1.0); 2407 } 2408 "" 2409 end 2410 2411 case unterminated_if_1 2412 version 300 es 2413 expect compile_fail 2414 both "" 2415 #version 300 es 2416 precision mediump float; 2417 ${DECLARATIONS} 2418 void main() 2419 { 2420 #if 1 2421 ${POSITION_FRAG_COLOR} = vec4(1.0); 2422 } 2423 "" 2424 end 2425 2426 case unterminated_if_2 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 ${POSITION_FRAG_COLOR} = vec4(1.0); 2437 } 2438 "" 2439 end 2440 2441 case unterminated_ifdef 2442 version 300 es 2443 expect compile_fail 2444 both "" 2445 #version 300 es 2446 precision mediump float; 2447 ${DECLARATIONS} 2448 void main() 2449 { 2450 #ifdef FOOBAR 2451 ${POSITION_FRAG_COLOR} = vec4(1.0); 2452 } 2453 "" 2454 end 2455 2456 case unterminated_ifndef 2457 version 300 es 2458 expect compile_fail 2459 both "" 2460 #version 300 es 2461 precision mediump float; 2462 ${DECLARATIONS} 2463 void main() 2464 { 2465 #ifndef GL_ES 2466 ${POSITION_FRAG_COLOR} = vec4(1.0); 2467 } 2468 "" 2469 end 2470 2471 case unterminated_else_1 2472 version 300 es 2473 expect compile_fail 2474 both "" 2475 #version 300 es 2476 precision mediump float; 2477 ${DECLARATIONS} 2478 void main() 2479 { 2480 #if 1 2481 #else 2482 ${POSITION_FRAG_COLOR} = vec4(1.0); 2483 } 2484 "" 2485 end 2486 2487 case unterminated_else_2 2488 version 300 es 2489 expect compile_fail 2490 both "" 2491 #version 300 es 2492 precision mediump float; 2493 ${DECLARATIONS} 2494 void main() 2495 { 2496 #if 0 2497 #else 2498 ${POSITION_FRAG_COLOR} = vec4(1.0); 2499 } 2500 "" 2501 end 2502 2503 case unterminated_elif_1 2504 version 300 es 2505 expect compile_fail 2506 both "" 2507 #version 300 es 2508 precision mediump float; 2509 ${DECLARATIONS} 2510 void main() 2511 { 2512 #if 0 2513 #elif 1 2514 ${POSITION_FRAG_COLOR} = vec4(1.0); 2515 } 2516 "" 2517 end 2518 2519 case unterminated_elif_2 2520 version 300 es 2521 expect compile_fail 2522 both "" 2523 #version 300 es 2524 precision mediump float; 2525 ${DECLARATIONS} 2526 void main() 2527 { 2528 #if 1 2529 #elif 0 2530 ${POSITION_FRAG_COLOR} = vec4(1.0); 2531 } 2532 "" 2533 end 2534 2535 case unterminated_elif_3 2536 version 300 es 2537 expect compile_fail 2538 both "" 2539 #version 300 es 2540 precision mediump float; 2541 ${DECLARATIONS} 2542 void main() 2543 { 2544 #if 0 2545 #elif 0 2546 ${POSITION_FRAG_COLOR} = vec4(2.0); 2547 } 2548 "" 2549 end 2550 2551 case elif_after_else 2552 version 300 es 2553 expect compile_fail 2554 both "" 2555 #version 300 es 2556 precision mediump float; 2557 ${DECLARATIONS} 2558 void main() 2559 { 2560 #if 0 2561 ${POSITION_FRAG_COLOR} = vec4(1.0); 2562 #else 2563 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2564 #elif 1 2565 ${POSITION_FRAG_COLOR} = vec4(0.0); 2566 #endif 2567 } 2568 "" 2569 end 2570 2571 case else_without_if 2572 version 300 es 2573 expect compile_fail 2574 both "" 2575 #version 300 es 2576 precision mediump float; 2577 ${DECLARATIONS} 2578 void main() 2579 { 2580 #else 2581 ${POSITION_FRAG_COLOR} = vec4(1.0); 2582 #endif 2583 } 2584 "" 2585 end 2586 2587 case elif_without_if 2588 version 300 es 2589 expect compile_fail 2590 both "" 2591 #version 300 es 2592 precision mediump float; 2593 ${DECLARATIONS} 2594 void main() 2595 { 2596 #elif 1 2597 ${POSITION_FRAG_COLOR} = vec4(1.0); 2598 #endif 2599 } 2600 "" 2601 end 2602 2603 case endif_without_if 2604 version 300 es 2605 expect compile_fail 2606 both "" 2607 #version 300 es 2608 precision mediump float; 2609 ${DECLARATIONS} 2610 void main() 2611 { 2612 ${POSITION_FRAG_COLOR} = vec4(1.0); 2613 #endif 2614 } 2615 "" 2616 end 2617 2618 case else_after_else 2619 version 300 es 2620 expect compile_fail 2621 both "" 2622 #version 300 es 2623 precision mediump float; 2624 ${DECLARATIONS} 2625 void main() 2626 { 2627 #if !GL_ES 2628 ${POSITION_FRAG_COLOR} = vec4(1.0); 2629 #else 2630 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2631 #else 2632 ${POSITION_FRAG_COLOR} = vec4(-1.0); 2633 #endif 2634 } 2635 "" 2636 end 2637 2638 case nested_elif_without_if 2639 version 300 es 2640 expect compile_fail 2641 both "" 2642 #version 300 es 2643 precision mediump float; 2644 ${DECLARATIONS} 2645 void main() 2646 { 2647 #if 1 2648 ${POSITION_FRAG_COLOR} = vec4(1.0); 2649 # elif 2650 ${POSITION_FRAG_COLOR} = vec4(0.0); 2651 # endif 2652 #endif 2653 } 2654 "" 2655 end 2656 2657 case if_float 2658 version 300 es 2659 expect compile_fail 2660 both "" 2661 #version 300 es 2662 precision mediump float; 2663 ${DECLARATIONS} 2664 void main() 2665 { 2666 #if 1.231 2667 ${POSITION_FRAG_COLOR} = vec4(1.0); 2668 # elif 2669 ${POSITION_FRAG_COLOR} = vec4(0.0); 2670 # endif 2671 #endif 2672 } 2673 "" 2674 end 2675 2676 case tokens_after_if 2677 version 300 es 2678 expect compile_fail 2679 both "" 2680 #version 300 es 2681 precision mediump float; 2682 ${DECLARATIONS} 2683 void main() 2684 { 2685 #if 1 foobar 2686 ${POSITION_FRAG_COLOR} = vec4(1.0); 2687 #endif 2688 } 2689 "" 2690 end 2691 2692 case tokens_after_elif 2693 version 300 es 2694 expect compile_fail 2695 both "" 2696 #version 300 es 2697 precision mediump float; 2698 ${DECLARATIONS} 2699 void main() 2700 { 2701 #if 0 2702 #elif foobar 2703 ${POSITION_FRAG_COLOR} = vec4(1.0); 2704 #endif 2705 } 2706 "" 2707 end 2708 2709 case tokens_after_else 2710 version 300 es 2711 expect compile_fail 2712 both "" 2713 #version 300 es 2714 precision mediump float; 2715 ${DECLARATIONS} 2716 void main() 2717 { 2718 #if 1 2719 #else foobar 1.231 2720 #endif 2721 ${POSITION_FRAG_COLOR} = vec4(1.0); 2722 } 2723 "" 2724 end 2725 2726 case tokens_after_endif 2727 version 300 es 2728 expect compile_fail 2729 both "" 2730 #version 300 es 2731 precision mediump float; 2732 ${DECLARATIONS} 2733 void main() 2734 { 2735 #if 1 2736 #else 2737 #endif foobar 2738 ${POSITION_FRAG_COLOR} = vec4(1.0); 2739 } 2740 "" 2741 end 2742 2743 case tokens_after_ifdef 2744 version 300 es 2745 expect compile_fail 2746 both "" 2747 #version 300 es 2748 precision mediump float; 2749 ${DECLARATIONS} 2750 void main() 2751 { 2752 #ifdef FOOBAR foobar 2753 #else 2754 #endif 2755 ${POSITION_FRAG_COLOR} = vec4(1.0); 2756 } 2757 "" 2758 end 2759 2760 case tokens_after_ifndef 2761 version 300 es 2762 expect compile_fail 2763 both "" 2764 #version 300 es 2765 precision mediump float; 2766 ${DECLARATIONS} 2767 void main() 2768 { 2769 #ifndef FOOBAR ,, +- << barbar 2770 #else 2771 #endif 2772 ${POSITION_FRAG_COLOR} = vec4(1.0); 2773 } 2774 "" 2775 end 2776 2777 case unterminated_nested_blocks 2778 version 300 es 2779 expect compile_fail 2780 both "" 2781 #version 300 es 2782 precision mediump float; 2783 ${DECLARATIONS} 2784 void main() 2785 { 2786 #if 1 2787 # if 1 2788 ${POSITION_FRAG_COLOR} = vec4(1.0); 2789 } 2790 "" 2791 end 2792 2793 end # invalid_conditionals 2794 2795 group conditionals "Conditionals Tests" 2796 2797 case ifdef_1 2798 version 300 es 2799 values { output float out0 = 1.0; } 2800 both "" 2801 #version 300 es 2802 #define AAA 2803 precision mediump float; 2804 ${DECLARATIONS} 2805 void main() 2806 { 2807 #ifdef AAA 2808 out0 = 1.0; 2809 #else 2810 out0 = -1.0; 2811 #endif 2812 ${OUTPUT} 2813 } 2814 "" 2815 end 2816 2817 case ifdef_2 2818 version 300 es 2819 values { output float out0 = 1.0; } 2820 both "" 2821 #version 300 es 2822 #define AAA 2823 precision mediump float; 2824 ${DECLARATIONS} 2825 void main() 2826 { 2827 #if defined ( AAA) 2828 out0 = 1.0; 2829 #else 2830 out0 = -1.0; 2831 #endif 2832 ${OUTPUT} 2833 } 2834 "" 2835 end 2836 2837 case ifdef_3 2838 version 300 es 2839 values { output float out0 = 1.0; } 2840 both "" 2841 #version 300 es 2842 precision mediump float; 2843 ${DECLARATIONS} 2844 void main() 2845 { 2846 #ifdef AAA 2847 out0 = -1.0; 2848 #else 2849 out0 = 1.0; 2850 #endif 2851 ${OUTPUT} 2852 } 2853 "" 2854 end 2855 2856 case ifndef_1 2857 version 300 es 2858 values { output float out0 = 1.0; } 2859 both "" 2860 #version 300 es 2861 precision mediump float; 2862 ${DECLARATIONS} 2863 void main() 2864 { 2865 #ifndef AAA 2866 out0 = 1.0; 2867 #else 2868 out0 = -1.0; 2869 #endif 2870 ${OUTPUT} 2871 } 2872 "" 2873 end 2874 2875 case ifndef_2 2876 version 300 es 2877 values { output float out0 = 1.0; } 2878 both "" 2879 #version 300 es 2880 precision mediump float; 2881 ${DECLARATIONS} 2882 #define AAA 2883 void main() 2884 { 2885 #ifndef AAA 2886 out0 = -1.0; 2887 #else 2888 out0 = 1.0; 2889 #endif 2890 ${OUTPUT} 2891 } 2892 "" 2893 end 2894 2895 case mixed_conditional_inclusion 2896 version 300 es 2897 values { output float out0 = 1.0; } 2898 both "" 2899 #version 300 es 2900 precision mediump float; 2901 ${DECLARATIONS} 2902 void main() 2903 { 2904 #ifndef AAA 2905 out0 = 1.0; 2906 #elif 1 2907 out0 = -1.0; 2908 #endif 2909 ${OUTPUT} 2910 } 2911 "" 2912 end 2913 2914 case nested_if_1 2915 version 300 es 2916 values { output float out0 = 1.0; } 2917 both "" 2918 #version 300 es 2919 precision mediump float; 2920 ${DECLARATIONS} 2921 void main() 2922 { 2923 #if GL_ES 2924 # if __VERSION__ != 300 2925 out0 = -1.0; 2926 # else 2927 out0 = 1.0; 2928 # endif 2929 #endif 2930 ${OUTPUT} 2931 } 2932 "" 2933 end 2934 2935 case nested_if_2 2936 version 300 es 2937 values { output float out0 = 1.0; } 2938 both "" 2939 #version 300 es 2940 precision mediump float; 2941 ${DECLARATIONS} 2942 void main() 2943 { 2944 #if 1 2945 # if 0 2946 out0 = -1.0; 2947 # else 2948 # if 0 2949 out0 = -1.0; 2950 # elif 1 2951 out0 = 1.0; 2952 # else 2953 out0 = -1.0; 2954 # endif 2955 # endif 2956 #endif 2957 ${OUTPUT} 2958 } 2959 "" 2960 end 2961 2962 case nested_if_3 2963 version 300 es 2964 values { output float out0 = 1.0; } 2965 both "" 2966 #version 300 es 2967 precision mediump float; 2968 ${DECLARATIONS} 2969 void main() 2970 { 2971 #if 0 2972 # if 1 2973 out0 = -1.0; 2974 # endif 2975 #else 2976 out0 = 1.0; 2977 #endif 2978 ${OUTPUT} 2979 } 2980 "" 2981 end 2982 2983 end # conditionals 2984 2985 group directive "Directive Tests" 2986 2987 case version_is_less 2988 expect compile_fail 2989 version 300 es 2990 both "" 2991 #version 299 es 2992 precision mediump float; 2993 ${DECLARATIONS} 2994 void main() 2995 { 2996 ${POSITION_FRAG_COLOR} = vec4(1.0); 2997 } 2998 "" 2999 end 3000 3001 case version_is_more 3002 expect compile_fail 3003 version 300 es 3004 both "" 3005 #version 301 es 3006 precision mediump float; 3007 ${DECLARATIONS} 3008 void main() 3009 { 3010 ${POSITION_FRAG_COLOR} = vec4(1.0); 3011 } 3012 "" 3013 end 3014 3015 case version_missing_es 3016 expect compile_fail 3017 version 300 es 3018 both "" 3019 #version 300 3020 precision mediump float; 3021 ${DECLARATIONS} 3022 void main() 3023 { 3024 ${POSITION_FRAG_COLOR} = vec4(1.0); 3025 } 3026 "" 3027 end 3028 3029 case version_missing 3030 expect compile_fail 3031 version 300 es 3032 both "" 3033 #version 3034 precision mediump float; 3035 ${DECLARATIONS} 3036 void main() 3037 { 3038 ${POSITION_FRAG_COLOR} = vec4(1.0); 3039 } 3040 "" 3041 end 3042 3043 case version_not_first_statement_1 3044 expect compile_fail 3045 version 300 es 3046 both "" 3047 precision mediump float; 3048 #version 300 es 3049 ${DECLARATIONS} 3050 void main() 3051 { 3052 ${POSITION_FRAG_COLOR} = vec4(1.0); 3053 } 3054 "" 3055 end 3056 3057 case version_not_first_statement_2 3058 expect compile_fail 3059 version 300 es 3060 both "" 3061 #define FOO BAR 3062 #version 300 es 3063 precision mediump float; 3064 ${DECLARATIONS} 3065 void main() 3066 { 3067 ${POSITION_FRAG_COLOR} = vec4(1.0); 3068 } 3069 "" 3070 end 3071 3072 case version_invalid_token_1 3073 expect compile_fail 3074 version 300 es 3075 both "" 3076 #version 300 es.0 3077 precision mediump float; 3078 ${DECLARATIONS} 3079 void main() 3080 { 3081 ${POSITION_FRAG_COLOR} = vec4(1.0); 3082 } 3083 "" 3084 end 3085 3086 case version_invalid_token_2 3087 expect compile_fail 3088 version 300 es 3089 both "" 3090 #version foobar 3091 precision mediump float; 3092 ${DECLARATIONS} 3093 void main() 3094 { 3095 ${POSITION_FRAG_COLOR} = vec4(1.0); 3096 } 3097 "" 3098 end 3099 3100 case invalid_version 3101 expect compile_fail 3102 version 300 es 3103 both "" 3104 #version AAA 3105 precision mediump float; 3106 ${DECLARATIONS} 3107 void main() 3108 { 3109 ${POSITION_FRAG_COLOR} = vec4(1.0); 3110 } 3111 "" 3112 end 3113 3114 case additional_tokens 3115 expect compile_fail 3116 version 300 es 3117 both "" 3118 #version 300 es foobar 3119 precision mediump float; 3120 ${DECLARATIONS} 3121 void main() 3122 { 3123 ${POSITION_FRAG_COLOR} = vec4(1.0); 3124 } 3125 "" 3126 end 3127 3128 case error_with_no_tokens 3129 version 300 es 3130 expect compile_fail 3131 both "" 3132 #version 300 es 3133 #error 3134 precision mediump float; 3135 ${DECLARATIONS} 3136 void main() 3137 { 3138 ${POSITION_FRAG_COLOR} = vec4(1.0); 3139 } 3140 "" 3141 end 3142 3143 case error 3144 version 300 es 3145 expect compile_fail 3146 both "" 3147 #version 300 es 3148 #define AAA asdf 3149 #error 1 * AAA /* comment */ 3150 precision mediump float; 3151 ${DECLARATIONS} 3152 void main() 3153 { 3154 ${POSITION_FRAG_COLOR} = vec4(1.0); 3155 } 3156 "" 3157 end 3158 3159 end # directive 3160 3161 group builtin "Built-in Symbol Tests" 3162 3163 case line 3164 version 300 es 3165 values { output float out0 = 1.0; } 3166 both "" 3167 #version 300 es 3168 precision mediump float; 3169 ${DECLARATIONS} 3170 void main() 3171 { 3172 #line 1 3173 out0 = float(__LINE__); 3174 ${OUTPUT} 3175 } 3176 "" 3177 end 3178 3179 case line_and_file 3180 version 300 es 3181 values { output vec4 out0 = vec4(234.0, 234.0, 10.0, 10.0); } 3182 both "" 3183 #version 300 es 3184 precision mediump float; 3185 ${DECLARATIONS} 3186 void main() 3187 { 3188 #line 234 10 3189 out0 = vec4(__LINE__, __LINE__, __FILE__, __FILE__); 3190 ${OUTPUT} 3191 } 3192 "" 3193 end 3194 3195 case line_expression 3196 version 300 es 3197 values { output float out0 = 20.0; } 3198 both "" 3199 #version 300 es 3200 precision mediump float; 3201 ${DECLARATIONS} 3202 void main() 3203 { 3204 #line +20 3205 out0 = float(__LINE__); 3206 ${OUTPUT} 3207 } 3208 "" 3209 end 3210 3211 case line_and_file_expression 3212 version 300 es 3213 values { output vec4 out0 = vec4(243.0, 243.0, 10.0, 10.0); } 3214 both "" 3215 #version 300 es 3216 precision mediump float; 3217 ${DECLARATIONS} 3218 void main() 3219 { 3220 #line (233 +10) (+10) 3221 out0 = vec4(__LINE__, __LINE__, __FILE__, __FILE__); 3222 ${OUTPUT} 3223 } 3224 "" 3225 end 3226 3227 case line_defined_1 3228 version 300 es 3229 values { output float out0 = 4.0; } 3230 both "" 3231 #version 300 es 3232 precision mediump float; 3233 ${DECLARATIONS} 3234 void main() 3235 { 3236 #define A 4 3237 #line A 3238 out0 = float(__LINE__); 3239 ${OUTPUT} 3240 } 3241 "" 3242 end 3243 3244 case line_defined_2 3245 version 300 es 3246 values { output vec4 out0 = vec4(234.0, 234.0, 10.0, 10.0); } 3247 both "" 3248 #version 300 es 3249 precision mediump float; 3250 ${DECLARATIONS} 3251 void main() 3252 { 3253 #define A 10 3254 #line 234 A 3255 out0 = vec4(__LINE__, __LINE__, __FILE__, __FILE__); 3256 ${OUTPUT} 3257 } 3258 "" 3259 end 3260 3261 case empty_line 3262 version 300 es 3263 expect compile_fail 3264 both "" 3265 #version 300 es 3266 precision mediump float; 3267 ${DECLARATIONS} 3268 void main() 3269 { 3270 #line 3271 ${POSITION_FRAG_COLOR} = vec4(1.0); 3272 } 3273 "" 3274 end 3275 3276 case invalid_line_file_1 3277 version 300 es 3278 expect compile_fail 3279 both "" 3280 #version 300 es 3281 precision mediump float; 3282 ${DECLARATIONS} 3283 void main() 3284 { 3285 #line 22 1.234 3286 ${POSITION_FRAG_COLOR} = vec4(__LINE__, __LINE__, __FILE__, __FILE__); 3287 } 3288 "" 3289 end 3290 3291 case invalid_line_file_3 3292 version 300 es 3293 expect compile_fail 3294 both "" 3295 #version 300 es 3296 precision mediump float; 3297 ${DECLARATIONS} 3298 void main() 3299 { 3300 #line 233 10 2 3301 ${POSITION_FRAG_COLOR} = vec4(__LINE__, __LINE__, __FILE__, __FILE__); 3302 } 3303 "" 3304 end 3305 3306 case invalid_line_file_4 3307 version 300 es 3308 expect compile_fail 3309 both "" 3310 #version 300 es 3311 precision mediump float; 3312 ${DECLARATIONS} 3313 void main() 3314 { 3315 #line foobar 3316 ${POSITION_FRAG_COLOR} = vec4(__LINE__, __LINE__, __FILE__, __FILE__); 3317 } 3318 "" 3319 end 3320 3321 end # builtin 3322 3323 group pragmas "Pragma Tests" 3324 3325 case pragma_vertex 3326 version 300 es 3327 values { output float out0 = 1.0; } 3328 vertex "" 3329 #version 300 es 3330 #pragma 3331 #pragma STDGL invariant(all) 3332 #pragma debug(off) 3333 #pragma optimize(off) 3334 3335 ${VERTEX_DECLARATIONS} 3336 void main() 3337 { 3338 ${VERTEX_OUTPUT} 3339 } 3340 "" 3341 fragment "" 3342 #version 300 es 3343 precision mediump float; 3344 ${FRAGMENT_DECLARATIONS} 3345 void main() 3346 { 3347 out0 = 1.0; 3348 ${FRAGMENT_OUTPUT} 3349 } 3350 "" 3351 end 3352 3353 case pragma_fragment 3354 version 300 es 3355 values { output float out0 = 1.0; } 3356 vertex "" 3357 #version 300 es 3358 ${VERTEX_DECLARATIONS} 3359 void main() 3360 { 3361 ${VERTEX_OUTPUT} 3362 } 3363 "" 3364 fragment "" 3365 #version 300 es 3366 #pragma 3367 #pragma debug(off) 3368 #pragma optimize(off) 3369 3370 precision mediump float; 3371 ${FRAGMENT_DECLARATIONS} 3372 void main() 3373 { 3374 out0 = 1.0; 3375 ${FRAGMENT_OUTPUT} 3376 } 3377 "" 3378 end 3379 3380 case pragma_macro_exp 3381 version 300 es 3382 values { output float out0 = 1.0; } 3383 both "" 3384 #version 300 es 3385 #define off INVALID 3386 /* pragma line not macro expanded */ 3387 #pragma debug(off) 3388 3389 precision mediump float; 3390 ${DECLARATIONS} 3391 void main() 3392 { 3393 out0 = 1.0; 3394 ${OUTPUT} 3395 } 3396 "" 3397 end 3398 3399 case pragma_unrecognized_debug 3400 version 300 es 3401 expect build_successful 3402 both "" 3403 #version 300 es 3404 #pragma debug(1.23) 3405 3406 // unrecognized preprocessor token 3407 3408 precision mediump float; 3409 ${DECLARATIONS} 3410 void main() 3411 { 3412 ${POSITION_FRAG_COLOR} = vec4(1.0); 3413 } 3414 "" 3415 end 3416 3417 case pragma_unrecognized_token 3418 version 300 es 3419 expect build_successful 3420 both "" 3421 #version 300 es 3422 #pragma 3423 3424 // trailing bytes form a valid but unrecognized preprocessor token 3425 3426 precision mediump float; 3427 ${DECLARATIONS} 3428 void main() 3429 { 3430 ${POSITION_FRAG_COLOR} = vec4(1.0); 3431 } 3432 "" 3433 end 3434 3435 end # pragmas 3436 3437 group extensions "Extension Tests" 3438 3439 case basic 3440 version 300 es 3441 values { output float out0 = 1.0; } 3442 both "" 3443 #version 300 es 3444 #extension all : warn 3445 3446 precision mediump float; 3447 ${DECLARATIONS} 3448 void main() 3449 { 3450 out0 = 1.0; 3451 ${OUTPUT} 3452 } 3453 "" 3454 end 3455 3456 case macro_exp 3457 version 300 es 3458 values { output float out0 = 1.0; } 3459 both "" 3460 #version 300 es 3461 #define warn enable 3462 3463 #extension all : warn 3464 3465 precision mediump float; 3466 ${DECLARATIONS} 3467 void main() 3468 { 3469 out0 = 1.0; 3470 ${OUTPUT} 3471 } 3472 "" 3473 end 3474 3475 case missing_extension_name 3476 version 300 es 3477 expect compile_fail 3478 both "" 3479 #version 300 es 3480 #extension 3481 precision mediump float; 3482 ${DECLARATIONS} 3483 void main() 3484 { 3485 ${POSITION_FRAG_COLOR} = vec4(1.0); 3486 } 3487 "" 3488 end 3489 3490 case invalid_extension_name 3491 version 300 es 3492 expect compile_fail 3493 both "" 3494 #version 300 es 3495 #extension 2 : all 3496 precision mediump float; 3497 ${DECLARATIONS} 3498 void main() 3499 { 3500 ${POSITION_FRAG_COLOR} = vec4(1.0); 3501 } 3502 "" 3503 end 3504 3505 case missing_colon 3506 version 300 es 3507 expect compile_fail 3508 both "" 3509 #version 300 es 3510 #extension all 3511 precision mediump float; 3512 ${DECLARATIONS} 3513 void main() 3514 { 3515 ${POSITION_FRAG_COLOR} = vec4(1.0); 3516 } 3517 "" 3518 end 3519 3520 case expected_colon 3521 version 300 es 3522 expect compile_fail 3523 both "" 3524 #version 300 es 3525 #extension all ; 3526 precision mediump float; 3527 ${DECLARATIONS} 3528 void main() 3529 { 3530 ${POSITION_FRAG_COLOR} = vec4(1.0); 3531 } 3532 "" 3533 end 3534 3535 case missing_behavior 3536 version 300 es 3537 expect compile_fail 3538 both "" 3539 #version 300 es 3540 #extension all : 3541 precision mediump float; 3542 ${DECLARATIONS} 3543 void main() 3544 { 3545 ${POSITION_FRAG_COLOR} = vec4(1.0); 3546 } 3547 "" 3548 end 3549 3550 case invalid_behavior_1 3551 version 300 es 3552 expect compile_fail 3553 both "" 3554 #version 300 es 3555 #extension all : WARN 3556 precision mediump float; 3557 ${DECLARATIONS} 3558 void main() 3559 { 3560 ${POSITION_FRAG_COLOR} = vec4(1.0); 3561 } 3562 "" 3563 end 3564 3565 case invalid_behavior_2 3566 version 300 es 3567 expect compile_fail 3568 both "" 3569 #version 300 es 3570 #extension all : require 3571 precision mediump float; 3572 ${DECLARATIONS} 3573 void main() 3574 { 3575 ${POSITION_FRAG_COLOR} = vec4(1.0); 3576 } 3577 "" 3578 end 3579 3580 case invalid_char_in_name 3581 version 300 es 3582 expect compile_fail 3583 both "" 3584 #version 300 es 3585 #extension all : warn 3586 precision mediump float; 3587 ${DECLARATIONS} 3588 void main() 3589 { 3590 ${POSITION_FRAG_COLOR} = vec4(1.0); 3591 } 3592 "" 3593 end 3594 3595 case invalid_char_in_behavior 3596 version 300 es 3597 expect compile_fail 3598 both "" 3599 #version 300 es 3600 #extension all : warn 3601 precision mediump float; 3602 ${DECLARATIONS} 3603 void main() 3604 { 3605 ${POSITION_FRAG_COLOR} = vec4(1.0); 3606 } 3607 "" 3608 end 3609 3610 case unterminated_comment 3611 version 300 es 3612 expect compile_fail 3613 both "" 3614 #version 300 es 3615 #extension all : warn /*asd 3616 precision mediump float; 3617 ${DECLARATIONS} 3618 void main() 3619 { 3620 ${POSITION_FRAG_COLOR} = vec4(1.0); 3621 } 3622 "" 3623 end 3624 3625 case after_non_preprocessing_tokens 3626 version 300 es 3627 expect compile_fail 3628 both "" 3629 #version 300 es 3630 #extension all : warn 3631 3632 precision mediump float; 3633 ${DECLARATIONS} 3634 void main() 3635 { 3636 #extension all : disable 3637 ${POSITION_FRAG_COLOR} = vec4(1.0); 3638 } 3639 "" 3640 end 3641 end # extensions 3642 3643 group expressions "Expression Tests" 3644 3645 case shift_left 3646 version 300 es 3647 values { output float out0 = 1.0; } 3648 both "" 3649 #version 300 es 3650 precision mediump float; 3651 ${DECLARATIONS} 3652 void main() 3653 { 3654 #define VAL 4 3655 out0 = 0.0; 3656 #if (VAL << 2) == 16 3657 out0 = 1.0; 3658 #endif 3659 ${OUTPUT} 3660 } 3661 "" 3662 end 3663 3664 case shift_right 3665 version 300 es 3666 values { output float out0 = 1.0; } 3667 both "" 3668 #version 300 es 3669 precision mediump float; 3670 ${DECLARATIONS} 3671 void main() 3672 { 3673 #define VAL 5 3674 out0 = 0.0; 3675 #if (VAL >> 1) == 2 3676 out0 = 1.0; 3677 #endif 3678 ${OUTPUT} 3679 } 3680 "" 3681 end 3682 3683 case cmp_less_than 3684 version 300 es 3685 values { output float out0 = 1.0; } 3686 both "" 3687 #version 300 es 3688 precision mediump float; 3689 ${DECLARATIONS} 3690 void main() 3691 { 3692 #define VAL 5 3693 out0 = 0.0; 3694 #if (VAL < 6) && (-VAL < -4) 3695 out0 = 1.0; 3696 #endif 3697 ${OUTPUT} 3698 } 3699 "" 3700 end 3701 3702 case less_or_equal 3703 version 300 es 3704 values { output float out0 = 1.0; } 3705 both "" 3706 #version 300 es 3707 precision mediump float; 3708 ${DECLARATIONS} 3709 void main() 3710 { 3711 #define VAL 6 3712 out0 = 0.0; 3713 #if (VAL <= 6) && (-VAL <= -6) 3714 out0 = 1.0; 3715 #endif 3716 ${OUTPUT} 3717 } 3718 "" 3719 end 3720 3721 case or 3722 version 300 es 3723 values { output float out0 = 1.0; } 3724 both "" 3725 #version 300 es 3726 precision mediump float; 3727 ${DECLARATIONS} 3728 void main() 3729 { 3730 #define VAL 6 3731 out0 = 0.0; 3732 #if (VAL | 5) == 7 3733 out0 = 1.0; 3734 #endif 3735 ${OUTPUT} 3736 } 3737 "" 3738 end 3739 3740 case and 3741 version 300 es 3742 values { output float out0 = 1.0; } 3743 both "" 3744 #version 300 es 3745 precision mediump float; 3746 ${DECLARATIONS} 3747 void main() 3748 { 3749 #define VAL 6 3750 out0 = 0.0; 3751 #if (VAL & 5) == 4 3752 out0 = 1.0; 3753 #endif 3754 ${OUTPUT} 3755 } 3756 "" 3757 end 3758 3759 case xor 3760 version 300 es 3761 values { output float out0 = 1.0; } 3762 both "" 3763 #version 300 es 3764 precision mediump float; 3765 ${DECLARATIONS} 3766 void main() 3767 { 3768 #define VAL 6 3769 out0 = 0.0; 3770 #if (VAL ^ 5) == 3 3771 out0 = 1.0; 3772 #endif 3773 ${OUTPUT} 3774 } 3775 "" 3776 end 3777 3778 case mod 3779 version 300 es 3780 values { output float out0 = 1.0; } 3781 both "" 3782 #version 300 es 3783 precision mediump float; 3784 ${DECLARATIONS} 3785 void main() 3786 { 3787 #define VAL 12 3788 out0 = 0.0; 3789 #if (VAL % 5) == 2 3790 out0 = 1.0; 3791 #endif 3792 ${OUTPUT} 3793 } 3794 "" 3795 end 3796 3797 case parenthesis_value 3798 version 300 es 3799 values { output float out0 = 1.0; } 3800 both "" 3801 #version 300 es 3802 precision mediump float; 3803 ${DECLARATIONS} 3804 void main() 3805 { 3806 #define VAL (( (4 ) ) ) 3807 out0 = 0.0; 3808 #if VAL >= 4 3809 out0 = 1.0; 3810 #endif 3811 ${OUTPUT} 3812 } 3813 "" 3814 end 3815 3816 case parenthesis_tricky 3817 version 300 es 3818 values { output float out0 = 1.0; } 3819 both "" 3820 #version 300 es 3821 precision mediump float; 3822 ${DECLARATIONS} 3823 void main() 3824 { 3825 #define VAL (( (4 ) ) 3826 out0 = 0.0; 3827 #if VAL) >= 4 3828 out0 = 1.0; 3829 #endif 3830 ${OUTPUT} 3831 } 3832 "" 3833 end 3834 3835 case parenthesis_if_no 3836 version 300 es 3837 values { output float out0 = 1.0; } 3838 both "" 3839 #version 300 es 3840 precision mediump float; 3841 ${DECLARATIONS} 3842 void main() 3843 { 3844 #define VAL 4 3845 out0 = 0.0; 3846 #if VAL >= 4 3847 out0 = 1.0; 3848 #endif 3849 ${OUTPUT} 3850 } 3851 "" 3852 end 3853 3854 case parenthesis_if 3855 version 300 es 3856 values { output float out0 = 1.0; } 3857 both "" 3858 #version 300 es 3859 precision mediump float; 3860 ${DECLARATIONS} 3861 void main() 3862 { 3863 #define VAL 4 3864 out0 = 0.0; 3865 #if (VAL >= 4) 3866 out0 = 1.0; 3867 #endif 3868 ${OUTPUT} 3869 } 3870 "" 3871 end 3872 3873 case parenthesis_multi_if 3874 version 300 es 3875 values { output float out0 = 1.0; } 3876 both "" 3877 #version 300 es 3878 precision mediump float; 3879 ${DECLARATIONS} 3880 void main() 3881 { 3882 #define VAL (4) 3883 out0 = 0.0; 3884 #if (((VAL)) >= (4)) 3885 out0 = 1.0; 3886 #endif 3887 ${OUTPUT} 3888 } 3889 "" 3890 end 3891 3892 case parenthesis_single_if 3893 version 300 es 3894 values { output float out0 = 1.0; } 3895 both "" 3896 #version 300 es 3897 precision mediump float; 3898 ${DECLARATIONS} 3899 void main() 3900 { 3901 #define VAL 4 3902 out0 = 0.0; 3903 #if (VAL >= 4) 3904 out0 = 1.0; 3905 #endif 3906 ${OUTPUT} 3907 } 3908 "" 3909 end 3910 3911 case parenthesis_ifelse_true 3912 version 300 es 3913 values { output float out0 = 1.0; } 3914 both "" 3915 #version 300 es 3916 precision mediump float; 3917 ${DECLARATIONS} 3918 void main() 3919 { 3920 #define VAL 4 3921 #if (VAL >= 4) 3922 out0 = 1.0; 3923 #else 3924 out0 = 0.0; 3925 #endif 3926 ${OUTPUT} 3927 } 3928 "" 3929 end 3930 3931 case parenthesis_ifelse_false 3932 version 300 es 3933 values { output float out0 = 1.0; } 3934 both "" 3935 #version 300 es 3936 precision mediump float; 3937 ${DECLARATIONS} 3938 void main() 3939 { 3940 #define VAL 4 3941 #if (VAL > 4) 3942 out0 = 0.0; 3943 #else 3944 out0 = 1.0; 3945 #endif 3946 ${OUTPUT} 3947 } 3948 "" 3949 end 3950 3951 case eval_basic_0 3952 version 300 es 3953 values { output float out0 = 1.0; } 3954 both "" 3955 #version 300 es 3956 precision mediump float; 3957 ${DECLARATIONS} 3958 void main() 3959 { 3960 #if -4 + 5 == 1 3961 out0 = 1.0; 3962 #else 3963 out0 = 0.0; 3964 #endif 3965 ${OUTPUT} 3966 } 3967 "" 3968 end 3969 3970 case eval_basic_1 3971 version 300 es 3972 values { output float out0 = 1.0; } 3973 both "" 3974 #version 300 es 3975 precision mediump float; 3976 ${DECLARATIONS} 3977 void main() 3978 { 3979 #if (2 * 2) - 3 >= 0 3980 out0 = 1.0; 3981 #else 3982 out0 = 0.0; 3983 #endif 3984 ${OUTPUT} 3985 } 3986 "" 3987 end 3988 3989 case eval_simple_precedence_0 3990 version 300 es 3991 values { output float out0 = 1.0; } 3992 both "" 3993 #version 300 es 3994 precision mediump float; 3995 ${DECLARATIONS} 3996 void main() 3997 { 3998 #if 2 * 3 - 3 == 3 3999 out0 = 1.0; 4000 #else 4001 out0 = 0.0; 4002 #endif 4003 ${OUTPUT} 4004 } 4005 "" 4006 end 4007 4008 case eval_simple_precedence_1 4009 version 300 es 4010 values { output float out0 = 1.0; } 4011 both "" 4012 #version 300 es 4013 precision mediump float; 4014 ${DECLARATIONS} 4015 void main() 4016 { 4017 #if 2 - 2 / 2 == 1 4018 out0 = 1.0; 4019 #else 4020 out0 = 0.0; 4021 #endif 4022 ${OUTPUT} 4023 } 4024 "" 4025 end 4026 4027 case defined_1 4028 version 300 es 4029 values { output float out0 = 1.0; } 4030 both "" 4031 #version 300 es 4032 precision mediump float; 4033 ${DECLARATIONS} 4034 #define X 0 4035 void main() 4036 { 4037 #if defined(X) 4038 out0 = 1.0; 4039 #else 4040 out0 = 0.0; 4041 #endif 4042 ${OUTPUT} 4043 } 4044 "" 4045 end 4046 4047 case defined_2 4048 version 300 es 4049 values { output float out0 = 1.0; } 4050 both "" 4051 #version 300 es 4052 precision mediump float; 4053 ${DECLARATIONS} 4054 #define X 0 4055 #define Y 1 4056 void main() 4057 { 4058 #if defined(X) == Y 4059 out0 = 1.0; 4060 #else 4061 out0 = 0.0; 4062 #endif 4063 ${OUTPUT} 4064 } 4065 "" 4066 end 4067 4068 case defined_3 4069 version 300 es 4070 values { output float out0 = 1.0; } 4071 both "" 4072 #version 300 es 4073 precision mediump float; 4074 ${DECLARATIONS} 4075 #define X 0 4076 #define Y 1 4077 void main() 4078 { 4079 #if defined(X) && defined(Y) 4080 out0 = 1.0; 4081 #else 4082 out0 = 0.0; 4083 #endif 4084 ${OUTPUT} 4085 } 4086 "" 4087 end 4088 4089 case defined_4 4090 version 300 es 4091 values { output float out0 = 1.0; } 4092 both "" 4093 #version 300 es 4094 precision mediump float; 4095 ${DECLARATIONS} 4096 #define X 0 4097 #define Y 1 4098 #undef X 4099 void main() 4100 { 4101 #if defined(X) && defined(Y) 4102 out0 = 0.0; 4103 #else 4104 out0 = 1.0; 4105 #endif 4106 ${OUTPUT} 4107 } 4108 "" 4109 end 4110 4111 case defined_5 4112 version 300 es 4113 values { output float out0 = 1.0; } 4114 both "" 4115 #version 300 es 4116 precision mediump float; 4117 ${DECLARATIONS} 4118 #define X 0 4119 #define Y 1 4120 #undef X 4121 void main() 4122 { 4123 #if defined(X) || defined(Y) 4124 out0 = 1.0; 4125 #else 4126 out0 = 0.0; 4127 #endif 4128 ${OUTPUT} 4129 } 4130 "" 4131 end 4132 4133 case defined_6 4134 version 300 es 4135 values { output float out0 = 1.0; } 4136 both "" 4137 #version 300 es 4138 precision mediump float; 4139 ${DECLARATIONS} 4140 #define X 0 4141 #define Y 1 4142 #undef Y 4143 void main() 4144 { 4145 #if defined(X) && (defined(Y) || (X == 0)) 4146 out0 = 1.0; 4147 #else 4148 out0 = 0.0; 4149 #endif 4150 ${OUTPUT} 4151 } 4152 "" 4153 end 4154 4155 end # expressions 4156 4157 group invalid_expressions "Invalid Expression Tests" 4158 4159 case invalid_unary_expr 4160 version 300 es 4161 expect compile_fail 4162 both "" 4163 #version 300 es 4164 precision mediump float; 4165 ${DECLARATIONS} 4166 void main() 4167 { 4168 #if ! 4169 ${POSITION_FRAG_COLOR} = vec4(1.0); 4170 } 4171 "" 4172 end 4173 4174 case invalid_binary_expr 4175 version 300 es 4176 expect compile_fail 4177 both "" 4178 #version 300 es 4179 precision mediump float; 4180 ${DECLARATIONS} 4181 void main() 4182 { 4183 #if 3+4+ 4184 ${POSITION_FRAG_COLOR} = vec4(1.0); 4185 } 4186 "" 4187 end 4188 4189 case missing_expr 4190 version 300 es 4191 expect compile_fail 4192 both "" 4193 #version 300 es 4194 precision mediump float; 4195 ${DECLARATIONS} 4196 void main() 4197 { 4198 #if 4199 ${POSITION_FRAG_COLOR} = vec4(1.0); 4200 } 4201 "" 4202 end 4203 4204 case invalid_expr_1 4205 version 300 es 4206 expect compile_fail 4207 both "" 4208 #version 300 es 4209 precision mediump float; 4210 ${DECLARATIONS} 4211 void main() 4212 { 4213 #if 4 4 4214 ${POSITION_FRAG_COLOR} = vec4(1.0); 4215 } 4216 "" 4217 end 4218 4219 case invalid_expr_2 4220 version 300 es 4221 expect compile_fail 4222 both "" 4223 #version 300 es 4224 precision mediump float; 4225 ${DECLARATIONS} 4226 void main() 4227 { 4228 #if 4 * * 4 4229 ${POSITION_FRAG_COLOR} = vec4(1.0); 4230 } 4231 "" 4232 end 4233 4234 case invalid_expr_3 4235 version 300 es 4236 expect compile_fail 4237 both "" 4238 #version 300 es 4239 precision mediump float; 4240 ${DECLARATIONS} 4241 void main() 4242 { 4243 #if (4)(4) 4244 ${POSITION_FRAG_COLOR} = vec4(1.0); 4245 } 4246 "" 4247 end 4248 4249 case unopened_parenthesis 4250 version 300 es 4251 expect compile_fail 4252 both "" 4253 #version 300 es 4254 precision mediump float; 4255 ${DECLARATIONS} 4256 void main() 4257 { 4258 #if 4) 4259 ${POSITION_FRAG_COLOR} = vec4(1.0); 4260 } 4261 "" 4262 end 4263 4264 case unclosed_parenthesis 4265 version 300 es 4266 expect compile_fail 4267 both "" 4268 #version 300 es 4269 precision mediump float; 4270 ${DECLARATIONS} 4271 void main() 4272 { 4273 #if ((4 + 7) 4274 ${POSITION_FRAG_COLOR} = vec4(1.0); 4275 } 4276 "" 4277 end 4278 4279 end # invalid_expressions 4280 4281 group operator_precedence "Operator precedence" 4282 4283 4284 case modulo_vs_not 4285 version 300 es 4286 values { output float out0 = 1.0; } 4287 both "" 4288 #version 300 es 4289 #if ( 8 % ! 0 ) == 0 4290 #define VAL 1.0 4291 #else 4292 #define VAL 0.0 4293 #endif 4294 4295 precision mediump float; 4296 ${DECLARATIONS} 4297 void main() 4298 { 4299 out0 = VAL; 4300 ${OUTPUT} 4301 } 4302 "" 4303 end 4304 4305 case div_vs_not 4306 version 300 es 4307 values { output float out0 = 1.0; } 4308 both "" 4309 #version 300 es 4310 #if ( 8 / ! 0 ) == 8 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_not 4327 version 300 es 4328 values { output float out0 = 1.0; } 4329 both "" 4330 #version 300 es 4331 #if ( 8 * ! 0 ) == 8 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 modulo_vs_bit_invert 4348 version 300 es 4349 values { output float out0 = 1.0; } 4350 both "" 4351 #version 300 es 4352 #if ( 8 % ~ 4 ) == 3 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 modulo_vs_minus 4369 version 300 es 4370 values { output float out0 = 1.0; } 4371 both "" 4372 #version 300 es 4373 #if ( 8 % - 2 ) == 0 4374 #define VAL 1.0 4375 #else 4376 #define VAL 0.0 4377 #endif 4378 4379 precision mediump float; 4380 ${DECLARATIONS} 4381 void main() 4382 { 4383 out0 = VAL; 4384 ${OUTPUT} 4385 } 4386 "" 4387 end 4388 4389 case modulo_vs_plus 4390 version 300 es 4391 values { output float out0 = 1.0; } 4392 both "" 4393 #version 300 es 4394 #if ( 8 % + 2 ) == 0 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 div_vs_bit_invert 4411 version 300 es 4412 values { output float out0 = 1.0; } 4413 both "" 4414 #version 300 es 4415 #if ( 8 / ~ 2 ) == -2 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 div_vs_minus 4432 version 300 es 4433 values { output float out0 = 1.0; } 4434 both "" 4435 #version 300 es 4436 #if ( 8 / - 2 ) == -4 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 div_vs_plus 4453 version 300 es 4454 values { output float out0 = 1.0; } 4455 both "" 4456 #version 300 es 4457 #if ( 8 / + 2 ) == 4 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 mul_vs_bit_invert 4474 version 300 es 4475 values { output float out0 = 1.0; } 4476 both "" 4477 #version 300 es 4478 #if ( 8 * ~ 2 ) == -24 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 mul_vs_minus 4495 version 300 es 4496 values { output float out0 = 1.0; } 4497 both "" 4498 #version 300 es 4499 #if ( 8 * - 2 ) == -16 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 mul_vs_plus 4516 version 300 es 4517 values { output float out0 = 1.0; } 4518 both "" 4519 #version 300 es 4520 #if ( 8 * + 2 ) == 16 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 sub_vs_modulo 4537 version 300 es 4538 values { output float out0 = 1.0; } 4539 both "" 4540 #version 300 es 4541 #if ( 8 - 3 % 2 ) == 7 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 sub_vs_div 4558 version 300 es 4559 values { output float out0 = 1.0; } 4560 both "" 4561 #version 300 es 4562 #if ( 8 - 3 / 2 ) == 7 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 sub_vs_mul 4579 version 300 es 4580 values { output float out0 = 1.0; } 4581 both "" 4582 #version 300 es 4583 #if ( 8 - 3 * 2 ) == 2 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 add_vs_modulo 4600 version 300 es 4601 values { output float out0 = 1.0; } 4602 both "" 4603 #version 300 es 4604 #if ( 8 + 3 % 2 ) == 9 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 add_vs_div 4621 version 300 es 4622 values { output float out0 = 1.0; } 4623 both "" 4624 #version 300 es 4625 #if ( 8 + 3 / 2 ) == 9 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 add_vs_mul 4642 version 300 es 4643 values { output float out0 = 1.0; } 4644 both "" 4645 #version 300 es 4646 #if ( 8 + 3 * 2 ) == 14 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 rshift_vs_sub 4663 version 300 es 4664 values { output float out0 = 1.0; } 4665 both "" 4666 #version 300 es 4667 #if ( 8 >> 3 - 2 ) == 4 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 rshift_vs_add 4684 version 300 es 4685 values { output float out0 = 1.0; } 4686 both "" 4687 #version 300 es 4688 #if ( 8 >> 3 + 2 ) == 0 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 lshift_vs_sub 4705 version 300 es 4706 values { output float out0 = 1.0; } 4707 both "" 4708 #version 300 es 4709 #if ( 8 << 3 - 2 ) == 16 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 lshift_vs_add 4726 version 300 es 4727 values { output float out0 = 1.0; } 4728 both "" 4729 #version 300 es 4730 #if ( 8 << 3 + 2 ) == 256 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 greater_or_equal_vs_rshift 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 greater_or_equal_vs_lshift 4768 version 300 es 4769 values { output float out0 = 1.0; } 4770 both "" 4771 #version 300 es 4772 #if ( 8 >= 3 << 2 ) == 0 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 less_or_equal_vs_rshift 4789 version 300 es 4790 values { output float out0 = 1.0; } 4791 both "" 4792 #version 300 es 4793 #if ( 8 <= 3 >> 2 ) == 0 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 less_or_equal_vs_lshift 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 greater_vs_rshift 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 greater_vs_lshift 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 less_vs_rshift 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 less_vs_lshift 4894 version 300 es 4895 values { output float out0 = 1.0; } 4896 both "" 4897 #version 300 es 4898 #if ( 8 < 3 << 2 ) == 1 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 not_equal_vs_greater_or_equal 4915 version 300 es 4916 values { output float out0 = 1.0; } 4917 both "" 4918 #version 300 es 4919 #if ( 8 != 3 >= 2 ) == 1 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 not_equal_vs_less_or_equal 4936 version 300 es 4937 values { output float out0 = 1.0; } 4938 both "" 4939 #version 300 es 4940 #if ( 8 != 3 <= 2 ) == 1 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 not_equal_vs_greater 4957 version 300 es 4958 values { output float out0 = 1.0; } 4959 both "" 4960 #version 300 es 4961 #if ( 8 != 3 > 2 ) == 1 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 not_equal_vs_less 4978 version 300 es 4979 values { output float out0 = 1.0; } 4980 both "" 4981 #version 300 es 4982 #if ( 8 != 3 < 2 ) == 1 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 equal_vs_greater_or_equal 4999 version 300 es 5000 values { output float out0 = 1.0; } 5001 both "" 5002 #version 300 es 5003 #if ( 8 == 3 >= 2 ) == 0 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 equal_vs_less_or_equal 5020 version 300 es 5021 values { output float out0 = 1.0; } 5022 both "" 5023 #version 300 es 5024 #if ( 8 == 3 <= 2 ) == 0 5025 #define VAL 1.0 5026 #else 5027 #define VAL 0.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 equal_vs_greater 5041 version 300 es 5042 values { output float out0 = 1.0; } 5043 both "" 5044 #version 300 es 5045 #if ( 8 == 3 > 2 ) == 0 5046 #define VAL 1.0 5047 #else 5048 #define VAL 0.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 equal_vs_less 5062 version 300 es 5063 values { output float out0 = 1.0; } 5064 both "" 5065 #version 300 es 5066 #if ( 8 == 3 < 2 ) == 0 5067 #define VAL 1.0 5068 #else 5069 #define VAL 0.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 case bitwise_and_vs_not_equal 5083 version 300 es 5084 values { output float out0 = 1.0; } 5085 both "" 5086 #version 300 es 5087 #if ( 8 & 3 != 2 ) == 0 5088 #define VAL 1.0 5089 #else 5090 #define VAL 0.0 5091 #endif 5092 5093 precision mediump float; 5094 ${DECLARATIONS} 5095 void main() 5096 { 5097 out0 = VAL; 5098 ${OUTPUT} 5099 } 5100 "" 5101 end 5102 5103 case bitwise_and_vs_equal 5104 version 300 es 5105 values { output float out0 = 1.0; } 5106 both "" 5107 #version 300 es 5108 #if ( 8 & 3 == 2 ) == 0 5109 #define VAL 1.0 5110 #else 5111 #define VAL 0.0 5112 #endif 5113 5114 precision mediump float; 5115 ${DECLARATIONS} 5116 void main() 5117 { 5118 out0 = VAL; 5119 ${OUTPUT} 5120 } 5121 "" 5122 end 5123 5124 case xor_vs_bitwise_and 5125 version 300 es 5126 values { output float out0 = 1.0; } 5127 both "" 5128 #version 300 es 5129 #if ( 8 ^ 3 & 2 ) == 10 5130 #define VAL 1.0 5131 #else 5132 #define VAL 0.0 5133 #endif 5134 5135 precision mediump float; 5136 ${DECLARATIONS} 5137 void main() 5138 { 5139 out0 = VAL; 5140 ${OUTPUT} 5141 } 5142 "" 5143 end 5144 5145 case bitwise_or_vs_xor 5146 version 300 es 5147 values { output float out0 = 1.0; } 5148 both "" 5149 #version 300 es 5150 #if ( 8 | 3 ^ 2 ) == 9 5151 #define VAL 1.0 5152 #else 5153 #define VAL 0.0 5154 #endif 5155 5156 precision mediump float; 5157 ${DECLARATIONS} 5158 void main() 5159 { 5160 out0 = VAL; 5161 ${OUTPUT} 5162 } 5163 "" 5164 end 5165 5166 case logical_and_vs_bitwise_or 5167 version 300 es 5168 values { output float out0 = 1.0; } 5169 both "" 5170 #version 300 es 5171 #if ( 0 && 3 | 2 ) 5172 #define VAL 0.0 5173 #else 5174 #define VAL 1.0 5175 #endif 5176 5177 precision mediump float; 5178 ${DECLARATIONS} 5179 void main() 5180 { 5181 out0 = VAL; 5182 ${OUTPUT} 5183 } 5184 "" 5185 end 5186 5187 case logical_and_vs_bitwise_and 5188 version 300 es 5189 values { output float out0 = 1.0; } 5190 both "" 5191 #version 300 es 5192 #if ( 0 && 4 & 2 ) 5193 #define VAL 0.0 5194 #else 5195 #define VAL 1.0 5196 #endif 5197 5198 precision mediump float; 5199 ${DECLARATIONS} 5200 void main() 5201 { 5202 out0 = VAL; 5203 ${OUTPUT} 5204 } 5205 "" 5206 end 5207 5208 case logical_or_vs_logical_and 5209 version 300 es 5210 values { output float out0 = 1.0; } 5211 both "" 5212 #version 300 es 5213 #if ( 0 || 4 && 0 ) 5214 #define VAL 0.0 5215 #else 5216 #define VAL 1.0 5217 #endif 5218 5219 precision mediump float; 5220 ${DECLARATIONS} 5221 void main() 5222 { 5223 out0 = VAL; 5224 ${OUTPUT} 5225 } 5226 "" 5227 end 5228 5229 end # operator_precedence 5230