1group 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 154end # basic 155 156group 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 278end # definitions 279 280group 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 331end # invalid_definitions 332 333group 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 662end # object_redefinitions 663 664group 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 682end # invalid_redefinitions 683 684group 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 836end # comments 837 838group 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 930end # line_continuation 931 932group 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 988end # function_definitions 989 990group 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 1074end # recursion 1075 1076group 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 1184end # functions_redefinitions 1185 1186group 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 1438end # invalid_function_definitions 1439 1440group 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 1477end # semantic 1478 1479group 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 1623end # predefined_macros 1624 1625group 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 1881end # conditional_inclusion 1882 1883group 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 2047end # invalid_ops 2048 2049group 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 2315end # undefined_identifiers 2316 2317group 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 2793end # invalid_conditionals 2794 2795group 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 2983end # conditionals 2984 2985group 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 3159end # directive 3160 3161group 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_defined_1 3196 version 300 es 3197 values { output float out0 = 4.0; } 3198 both "" 3199 #version 300 es 3200 precision mediump float; 3201 ${DECLARATIONS} 3202 void main() 3203 { 3204 #define A 4 3205 #line A 3206 out0 = float(__LINE__); 3207 ${OUTPUT} 3208 } 3209 "" 3210 end 3211 3212 case line_defined_2 3213 version 300 es 3214 values { output vec4 out0 = vec4(234.0, 234.0, 10.0, 10.0); } 3215 both "" 3216 #version 300 es 3217 precision mediump float; 3218 ${DECLARATIONS} 3219 void main() 3220 { 3221 #define A 10 3222 #line 234 A 3223 out0 = vec4(__LINE__, __LINE__, __FILE__, __FILE__); 3224 ${OUTPUT} 3225 } 3226 "" 3227 end 3228 3229 case empty_line 3230 version 300 es 3231 expect compile_fail 3232 both "" 3233 #version 300 es 3234 precision mediump float; 3235 ${DECLARATIONS} 3236 void main() 3237 { 3238 #line 3239 ${POSITION_FRAG_COLOR} = vec4(1.0); 3240 } 3241 "" 3242 end 3243 3244 case invalid_line_file_1 3245 version 300 es 3246 expect compile_fail 3247 both "" 3248 #version 300 es 3249 precision mediump float; 3250 ${DECLARATIONS} 3251 void main() 3252 { 3253 #line 22 1.234 3254 ${POSITION_FRAG_COLOR} = vec4(__LINE__, __LINE__, __FILE__, __FILE__); 3255 } 3256 "" 3257 end 3258 3259 case invalid_line_file_3 3260 version 300 es 3261 expect compile_fail 3262 both "" 3263 #version 300 es 3264 precision mediump float; 3265 ${DECLARATIONS} 3266 void main() 3267 { 3268 #line 233 10 2 3269 ${POSITION_FRAG_COLOR} = vec4(__LINE__, __LINE__, __FILE__, __FILE__); 3270 } 3271 "" 3272 end 3273 3274 case invalid_line_file_4 3275 version 300 es 3276 expect compile_fail 3277 both "" 3278 #version 300 es 3279 precision mediump float; 3280 ${DECLARATIONS} 3281 void main() 3282 { 3283 #line foobar 3284 ${POSITION_FRAG_COLOR} = vec4(__LINE__, __LINE__, __FILE__, __FILE__); 3285 } 3286 "" 3287 end 3288 3289end # builtin 3290 3291group pragmas "Pragma Tests" 3292 3293 case pragma_vertex 3294 version 300 es 3295 values { output float out0 = 1.0; } 3296 vertex "" 3297 #version 300 es 3298 #pragma 3299 #pragma STDGL invariant(all) 3300 #pragma debug(off) 3301 #pragma optimize(off) 3302 3303 ${VERTEX_DECLARATIONS} 3304 void main() 3305 { 3306 ${VERTEX_OUTPUT} 3307 } 3308 "" 3309 fragment "" 3310 #version 300 es 3311 precision mediump float; 3312 ${FRAGMENT_DECLARATIONS} 3313 void main() 3314 { 3315 out0 = 1.0; 3316 ${FRAGMENT_OUTPUT} 3317 } 3318 "" 3319 end 3320 3321 case pragma_fragment 3322 version 300 es 3323 values { output float out0 = 1.0; } 3324 vertex "" 3325 #version 300 es 3326 ${VERTEX_DECLARATIONS} 3327 void main() 3328 { 3329 ${VERTEX_OUTPUT} 3330 } 3331 "" 3332 fragment "" 3333 #version 300 es 3334 #pragma 3335 #pragma debug(off) 3336 #pragma optimize(off) 3337 3338 precision mediump float; 3339 ${FRAGMENT_DECLARATIONS} 3340 void main() 3341 { 3342 out0 = 1.0; 3343 ${FRAGMENT_OUTPUT} 3344 } 3345 "" 3346 end 3347 3348 case pragma_macro_exp 3349 version 300 es 3350 values { output float out0 = 1.0; } 3351 both "" 3352 #version 300 es 3353 #define off INVALID 3354 /* pragma line not macro expanded */ 3355 #pragma debug(off) 3356 3357 precision mediump float; 3358 ${DECLARATIONS} 3359 void main() 3360 { 3361 out0 = 1.0; 3362 ${OUTPUT} 3363 } 3364 "" 3365 end 3366 3367 case pragma_unrecognized_debug 3368 version 300 es 3369 expect build_successful 3370 both "" 3371 #version 300 es 3372 #pragma debug(1.23) 3373 3374 // unrecognized preprocessor token 3375 3376 precision mediump float; 3377 ${DECLARATIONS} 3378 void main() 3379 { 3380 ${POSITION_FRAG_COLOR} = vec4(1.0); 3381 } 3382 "" 3383 end 3384 3385 case pragma_unrecognized_token 3386 version 300 es 3387 expect build_successful 3388 both "" 3389 #version 300 es 3390 #pragma ¤¤½ 3391 3392 // trailing bytes form a valid but unrecognized preprocessor token 3393 3394 precision mediump float; 3395 ${DECLARATIONS} 3396 void main() 3397 { 3398 ${POSITION_FRAG_COLOR} = vec4(1.0); 3399 } 3400 "" 3401 end 3402 3403end # pragmas 3404 3405group extensions "Extension Tests" 3406 3407 case basic 3408 version 300 es 3409 values { output float out0 = 1.0; } 3410 both "" 3411 #version 300 es 3412 #extension all : warn 3413 3414 precision mediump float; 3415 ${DECLARATIONS} 3416 void main() 3417 { 3418 out0 = 1.0; 3419 ${OUTPUT} 3420 } 3421 "" 3422 end 3423 3424 case macro_exp 3425 version 300 es 3426 values { output float out0 = 1.0; } 3427 both "" 3428 #version 300 es 3429 #define warn enable 3430 3431 #extension all : warn 3432 3433 precision mediump float; 3434 ${DECLARATIONS} 3435 void main() 3436 { 3437 out0 = 1.0; 3438 ${OUTPUT} 3439 } 3440 "" 3441 end 3442 3443 case missing_extension_name 3444 version 300 es 3445 expect compile_fail 3446 both "" 3447 #version 300 es 3448 #extension 3449 precision mediump float; 3450 ${DECLARATIONS} 3451 void main() 3452 { 3453 ${POSITION_FRAG_COLOR} = vec4(1.0); 3454 } 3455 "" 3456 end 3457 3458 case invalid_extension_name 3459 version 300 es 3460 expect compile_fail 3461 both "" 3462 #version 300 es 3463 #extension 2 : all 3464 precision mediump float; 3465 ${DECLARATIONS} 3466 void main() 3467 { 3468 ${POSITION_FRAG_COLOR} = vec4(1.0); 3469 } 3470 "" 3471 end 3472 3473 case missing_colon 3474 version 300 es 3475 expect compile_fail 3476 both "" 3477 #version 300 es 3478 #extension all 3479 precision mediump float; 3480 ${DECLARATIONS} 3481 void main() 3482 { 3483 ${POSITION_FRAG_COLOR} = vec4(1.0); 3484 } 3485 "" 3486 end 3487 3488 case expected_colon 3489 version 300 es 3490 expect compile_fail 3491 both "" 3492 #version 300 es 3493 #extension all ; 3494 precision mediump float; 3495 ${DECLARATIONS} 3496 void main() 3497 { 3498 ${POSITION_FRAG_COLOR} = vec4(1.0); 3499 } 3500 "" 3501 end 3502 3503 case missing_behavior 3504 version 300 es 3505 expect compile_fail 3506 both "" 3507 #version 300 es 3508 #extension all : 3509 precision mediump float; 3510 ${DECLARATIONS} 3511 void main() 3512 { 3513 ${POSITION_FRAG_COLOR} = vec4(1.0); 3514 } 3515 "" 3516 end 3517 3518 case invalid_behavior_1 3519 version 300 es 3520 expect compile_fail 3521 both "" 3522 #version 300 es 3523 #extension all : WARN 3524 precision mediump float; 3525 ${DECLARATIONS} 3526 void main() 3527 { 3528 ${POSITION_FRAG_COLOR} = vec4(1.0); 3529 } 3530 "" 3531 end 3532 3533 case invalid_behavior_2 3534 version 300 es 3535 expect compile_fail 3536 both "" 3537 #version 300 es 3538 #extension all : require 3539 precision mediump float; 3540 ${DECLARATIONS} 3541 void main() 3542 { 3543 ${POSITION_FRAG_COLOR} = vec4(1.0); 3544 } 3545 "" 3546 end 3547 3548 case invalid_char_in_name 3549 version 300 es 3550 expect compile_fail 3551 both "" 3552 #version 300 es 3553 #extension all¤ : warn 3554 precision mediump float; 3555 ${DECLARATIONS} 3556 void main() 3557 { 3558 ${POSITION_FRAG_COLOR} = vec4(1.0); 3559 } 3560 "" 3561 end 3562 3563 case invalid_char_in_behavior 3564 version 300 es 3565 expect compile_fail 3566 both "" 3567 #version 300 es 3568 #extension all : war¤n 3569 precision mediump float; 3570 ${DECLARATIONS} 3571 void main() 3572 { 3573 ${POSITION_FRAG_COLOR} = vec4(1.0); 3574 } 3575 "" 3576 end 3577 3578 case unterminated_comment 3579 version 300 es 3580 expect compile_fail 3581 both "" 3582 #version 300 es 3583 #extension all : warn /*asd 3584 precision mediump float; 3585 ${DECLARATIONS} 3586 void main() 3587 { 3588 ${POSITION_FRAG_COLOR} = vec4(1.0); 3589 } 3590 "" 3591 end 3592 3593 case after_non_preprocessing_tokens 3594 version 300 es 3595 expect compile_fail 3596 both "" 3597 #version 300 es 3598 #extension all : warn 3599 3600 precision mediump float; 3601 ${DECLARATIONS} 3602 void main() 3603 { 3604 #extension all : disable 3605 ${POSITION_FRAG_COLOR} = vec4(1.0); 3606 } 3607 "" 3608 end 3609end # extensions 3610 3611group expressions "Expression Tests" 3612 3613 case shift_left 3614 version 300 es 3615 values { output float out0 = 1.0; } 3616 both "" 3617 #version 300 es 3618 precision mediump float; 3619 ${DECLARATIONS} 3620 void main() 3621 { 3622 #define VAL 4 3623 out0 = 0.0; 3624 #if (VAL << 2) == 16 3625 out0 = 1.0; 3626 #endif 3627 ${OUTPUT} 3628 } 3629 "" 3630 end 3631 3632 case shift_right 3633 version 300 es 3634 values { output float out0 = 1.0; } 3635 both "" 3636 #version 300 es 3637 precision mediump float; 3638 ${DECLARATIONS} 3639 void main() 3640 { 3641 #define VAL 5 3642 out0 = 0.0; 3643 #if (VAL >> 1) == 2 3644 out0 = 1.0; 3645 #endif 3646 ${OUTPUT} 3647 } 3648 "" 3649 end 3650 3651 case cmp_less_than 3652 version 300 es 3653 values { output float out0 = 1.0; } 3654 both "" 3655 #version 300 es 3656 precision mediump float; 3657 ${DECLARATIONS} 3658 void main() 3659 { 3660 #define VAL 5 3661 out0 = 0.0; 3662 #if (VAL < 6) && (-VAL < -4) 3663 out0 = 1.0; 3664 #endif 3665 ${OUTPUT} 3666 } 3667 "" 3668 end 3669 3670 case less_or_equal 3671 version 300 es 3672 values { output float out0 = 1.0; } 3673 both "" 3674 #version 300 es 3675 precision mediump float; 3676 ${DECLARATIONS} 3677 void main() 3678 { 3679 #define VAL 6 3680 out0 = 0.0; 3681 #if (VAL <= 6) && (-VAL <= -6) 3682 out0 = 1.0; 3683 #endif 3684 ${OUTPUT} 3685 } 3686 "" 3687 end 3688 3689 case or 3690 version 300 es 3691 values { output float out0 = 1.0; } 3692 both "" 3693 #version 300 es 3694 precision mediump float; 3695 ${DECLARATIONS} 3696 void main() 3697 { 3698 #define VAL 6 3699 out0 = 0.0; 3700 #if (VAL | 5) == 7 3701 out0 = 1.0; 3702 #endif 3703 ${OUTPUT} 3704 } 3705 "" 3706 end 3707 3708 case and 3709 version 300 es 3710 values { output float out0 = 1.0; } 3711 both "" 3712 #version 300 es 3713 precision mediump float; 3714 ${DECLARATIONS} 3715 void main() 3716 { 3717 #define VAL 6 3718 out0 = 0.0; 3719 #if (VAL & 5) == 4 3720 out0 = 1.0; 3721 #endif 3722 ${OUTPUT} 3723 } 3724 "" 3725 end 3726 3727 case xor 3728 version 300 es 3729 values { output float out0 = 1.0; } 3730 both "" 3731 #version 300 es 3732 precision mediump float; 3733 ${DECLARATIONS} 3734 void main() 3735 { 3736 #define VAL 6 3737 out0 = 0.0; 3738 #if (VAL ^ 5) == 3 3739 out0 = 1.0; 3740 #endif 3741 ${OUTPUT} 3742 } 3743 "" 3744 end 3745 3746 case mod 3747 version 300 es 3748 values { output float out0 = 1.0; } 3749 both "" 3750 #version 300 es 3751 precision mediump float; 3752 ${DECLARATIONS} 3753 void main() 3754 { 3755 #define VAL 12 3756 out0 = 0.0; 3757 #if (VAL % 5) == 2 3758 out0 = 1.0; 3759 #endif 3760 ${OUTPUT} 3761 } 3762 "" 3763 end 3764 3765 case parenthesis_value 3766 version 300 es 3767 values { output float out0 = 1.0; } 3768 both "" 3769 #version 300 es 3770 precision mediump float; 3771 ${DECLARATIONS} 3772 void main() 3773 { 3774 #define VAL (( (4 ) ) ) 3775 out0 = 0.0; 3776 #if VAL >= 4 3777 out0 = 1.0; 3778 #endif 3779 ${OUTPUT} 3780 } 3781 "" 3782 end 3783 3784 case parenthesis_tricky 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 out0 = 0.0; 3795 #if VAL) >= 4 3796 out0 = 1.0; 3797 #endif 3798 ${OUTPUT} 3799 } 3800 "" 3801 end 3802 3803 case parenthesis_if_no 3804 version 300 es 3805 values { output float out0 = 1.0; } 3806 both "" 3807 #version 300 es 3808 precision mediump float; 3809 ${DECLARATIONS} 3810 void main() 3811 { 3812 #define VAL 4 3813 out0 = 0.0; 3814 #if VAL >= 4 3815 out0 = 1.0; 3816 #endif 3817 ${OUTPUT} 3818 } 3819 "" 3820 end 3821 3822 case parenthesis_if 3823 version 300 es 3824 values { output float out0 = 1.0; } 3825 both "" 3826 #version 300 es 3827 precision mediump float; 3828 ${DECLARATIONS} 3829 void main() 3830 { 3831 #define VAL 4 3832 out0 = 0.0; 3833 #if (VAL >= 4) 3834 out0 = 1.0; 3835 #endif 3836 ${OUTPUT} 3837 } 3838 "" 3839 end 3840 3841 case parenthesis_multi_if 3842 version 300 es 3843 values { output float out0 = 1.0; } 3844 both "" 3845 #version 300 es 3846 precision mediump float; 3847 ${DECLARATIONS} 3848 void main() 3849 { 3850 #define VAL (4) 3851 out0 = 0.0; 3852 #if (((VAL)) >= (4)) 3853 out0 = 1.0; 3854 #endif 3855 ${OUTPUT} 3856 } 3857 "" 3858 end 3859 3860 case parenthesis_single_if 3861 version 300 es 3862 values { output float out0 = 1.0; } 3863 both "" 3864 #version 300 es 3865 precision mediump float; 3866 ${DECLARATIONS} 3867 void main() 3868 { 3869 #define VAL 4 3870 out0 = 0.0; 3871 #if (VAL >= 4) 3872 out0 = 1.0; 3873 #endif 3874 ${OUTPUT} 3875 } 3876 "" 3877 end 3878 3879 case parenthesis_ifelse_true 3880 version 300 es 3881 values { output float out0 = 1.0; } 3882 both "" 3883 #version 300 es 3884 precision mediump float; 3885 ${DECLARATIONS} 3886 void main() 3887 { 3888 #define VAL 4 3889 #if (VAL >= 4) 3890 out0 = 1.0; 3891 #else 3892 out0 = 0.0; 3893 #endif 3894 ${OUTPUT} 3895 } 3896 "" 3897 end 3898 3899 case parenthesis_ifelse_false 3900 version 300 es 3901 values { output float out0 = 1.0; } 3902 both "" 3903 #version 300 es 3904 precision mediump float; 3905 ${DECLARATIONS} 3906 void main() 3907 { 3908 #define VAL 4 3909 #if (VAL > 4) 3910 out0 = 0.0; 3911 #else 3912 out0 = 1.0; 3913 #endif 3914 ${OUTPUT} 3915 } 3916 "" 3917 end 3918 3919 case eval_basic_0 3920 version 300 es 3921 values { output float out0 = 1.0; } 3922 both "" 3923 #version 300 es 3924 precision mediump float; 3925 ${DECLARATIONS} 3926 void main() 3927 { 3928 #if -4 + 5 == 1 3929 out0 = 1.0; 3930 #else 3931 out0 = 0.0; 3932 #endif 3933 ${OUTPUT} 3934 } 3935 "" 3936 end 3937 3938 case eval_basic_1 3939 version 300 es 3940 values { output float out0 = 1.0; } 3941 both "" 3942 #version 300 es 3943 precision mediump float; 3944 ${DECLARATIONS} 3945 void main() 3946 { 3947 #if (2 * 2) - 3 >= 0 3948 out0 = 1.0; 3949 #else 3950 out0 = 0.0; 3951 #endif 3952 ${OUTPUT} 3953 } 3954 "" 3955 end 3956 3957 case eval_simple_precedence_0 3958 version 300 es 3959 values { output float out0 = 1.0; } 3960 both "" 3961 #version 300 es 3962 precision mediump float; 3963 ${DECLARATIONS} 3964 void main() 3965 { 3966 #if 2 * 3 - 3 == 3 3967 out0 = 1.0; 3968 #else 3969 out0 = 0.0; 3970 #endif 3971 ${OUTPUT} 3972 } 3973 "" 3974 end 3975 3976 case eval_simple_precedence_1 3977 version 300 es 3978 values { output float out0 = 1.0; } 3979 both "" 3980 #version 300 es 3981 precision mediump float; 3982 ${DECLARATIONS} 3983 void main() 3984 { 3985 #if 2 - 2 / 2 == 1 3986 out0 = 1.0; 3987 #else 3988 out0 = 0.0; 3989 #endif 3990 ${OUTPUT} 3991 } 3992 "" 3993 end 3994 3995 case defined_1 3996 version 300 es 3997 values { output float out0 = 1.0; } 3998 both "" 3999 #version 300 es 4000 precision mediump float; 4001 ${DECLARATIONS} 4002 #define X 0 4003 void main() 4004 { 4005 #if defined(X) 4006 out0 = 1.0; 4007 #else 4008 out0 = 0.0; 4009 #endif 4010 ${OUTPUT} 4011 } 4012 "" 4013 end 4014 4015 case defined_2 4016 version 300 es 4017 values { output float out0 = 1.0; } 4018 both "" 4019 #version 300 es 4020 precision mediump float; 4021 ${DECLARATIONS} 4022 #define X 0 4023 #define Y 1 4024 void main() 4025 { 4026 #if defined(X) == Y 4027 out0 = 1.0; 4028 #else 4029 out0 = 0.0; 4030 #endif 4031 ${OUTPUT} 4032 } 4033 "" 4034 end 4035 4036 case defined_3 4037 version 300 es 4038 values { output float out0 = 1.0; } 4039 both "" 4040 #version 300 es 4041 precision mediump float; 4042 ${DECLARATIONS} 4043 #define X 0 4044 #define Y 1 4045 void main() 4046 { 4047 #if defined(X) && defined(Y) 4048 out0 = 1.0; 4049 #else 4050 out0 = 0.0; 4051 #endif 4052 ${OUTPUT} 4053 } 4054 "" 4055 end 4056 4057 case defined_4 4058 version 300 es 4059 values { output float out0 = 1.0; } 4060 both "" 4061 #version 300 es 4062 precision mediump float; 4063 ${DECLARATIONS} 4064 #define X 0 4065 #define Y 1 4066 #undef X 4067 void main() 4068 { 4069 #if defined(X) && defined(Y) 4070 out0 = 0.0; 4071 #else 4072 out0 = 1.0; 4073 #endif 4074 ${OUTPUT} 4075 } 4076 "" 4077 end 4078 4079 case defined_5 4080 version 300 es 4081 values { output float out0 = 1.0; } 4082 both "" 4083 #version 300 es 4084 precision mediump float; 4085 ${DECLARATIONS} 4086 #define X 0 4087 #define Y 1 4088 #undef X 4089 void main() 4090 { 4091 #if defined(X) || defined(Y) 4092 out0 = 1.0; 4093 #else 4094 out0 = 0.0; 4095 #endif 4096 ${OUTPUT} 4097 } 4098 "" 4099 end 4100 4101 case defined_6 4102 version 300 es 4103 values { output float out0 = 1.0; } 4104 both "" 4105 #version 300 es 4106 precision mediump float; 4107 ${DECLARATIONS} 4108 #define X 0 4109 #define Y 1 4110 #undef Y 4111 void main() 4112 { 4113 #if defined(X) && (defined(Y) || (X == 0)) 4114 out0 = 1.0; 4115 #else 4116 out0 = 0.0; 4117 #endif 4118 ${OUTPUT} 4119 } 4120 "" 4121 end 4122 4123end # expressions 4124 4125group invalid_expressions "Invalid Expression Tests" 4126 4127 case invalid_unary_expr 4128 version 300 es 4129 expect compile_fail 4130 both "" 4131 #version 300 es 4132 precision mediump float; 4133 ${DECLARATIONS} 4134 void main() 4135 { 4136 #if ! 4137 ${POSITION_FRAG_COLOR} = vec4(1.0); 4138 } 4139 "" 4140 end 4141 4142 case invalid_binary_expr 4143 version 300 es 4144 expect compile_fail 4145 both "" 4146 #version 300 es 4147 precision mediump float; 4148 ${DECLARATIONS} 4149 void main() 4150 { 4151 #if 3+4+ 4152 ${POSITION_FRAG_COLOR} = vec4(1.0); 4153 } 4154 "" 4155 end 4156 4157 case missing_expr 4158 version 300 es 4159 expect compile_fail 4160 both "" 4161 #version 300 es 4162 precision mediump float; 4163 ${DECLARATIONS} 4164 void main() 4165 { 4166 #if 4167 ${POSITION_FRAG_COLOR} = vec4(1.0); 4168 } 4169 "" 4170 end 4171 4172 case invalid_expr_1 4173 version 300 es 4174 expect compile_fail 4175 both "" 4176 #version 300 es 4177 precision mediump float; 4178 ${DECLARATIONS} 4179 void main() 4180 { 4181 #if 4 4 4182 ${POSITION_FRAG_COLOR} = vec4(1.0); 4183 } 4184 "" 4185 end 4186 4187 case invalid_expr_2 4188 version 300 es 4189 expect compile_fail 4190 both "" 4191 #version 300 es 4192 precision mediump float; 4193 ${DECLARATIONS} 4194 void main() 4195 { 4196 #if 4 * * 4 4197 ${POSITION_FRAG_COLOR} = vec4(1.0); 4198 } 4199 "" 4200 end 4201 4202 case invalid_expr_3 4203 version 300 es 4204 expect compile_fail 4205 both "" 4206 #version 300 es 4207 precision mediump float; 4208 ${DECLARATIONS} 4209 void main() 4210 { 4211 #if (4)(4) 4212 ${POSITION_FRAG_COLOR} = vec4(1.0); 4213 } 4214 "" 4215 end 4216 4217 case unopened_parenthesis 4218 version 300 es 4219 expect compile_fail 4220 both "" 4221 #version 300 es 4222 precision mediump float; 4223 ${DECLARATIONS} 4224 void main() 4225 { 4226 #if 4) 4227 ${POSITION_FRAG_COLOR} = vec4(1.0); 4228 } 4229 "" 4230 end 4231 4232 case unclosed_parenthesis 4233 version 300 es 4234 expect compile_fail 4235 both "" 4236 #version 300 es 4237 precision mediump float; 4238 ${DECLARATIONS} 4239 void main() 4240 { 4241 #if ((4 + 7) 4242 ${POSITION_FRAG_COLOR} = vec4(1.0); 4243 } 4244 "" 4245 end 4246 4247end # invalid_expressions 4248 4249group operator_precedence "Operator precedence" 4250 4251 4252 case modulo_vs_not 4253 version 300 es 4254 values { output float out0 = 1.0; } 4255 both "" 4256 #version 300 es 4257 #if ( 8 % ! 0 ) == 0 4258 #define VAL 1.0 4259 #else 4260 #define VAL 0.0 4261 #endif 4262 4263 precision mediump float; 4264 ${DECLARATIONS} 4265 void main() 4266 { 4267 out0 = VAL; 4268 ${OUTPUT} 4269 } 4270 "" 4271 end 4272 4273 case div_vs_not 4274 version 300 es 4275 values { output float out0 = 1.0; } 4276 both "" 4277 #version 300 es 4278 #if ( 8 / ! 0 ) == 8 4279 #define VAL 1.0 4280 #else 4281 #define VAL 0.0 4282 #endif 4283 4284 precision mediump float; 4285 ${DECLARATIONS} 4286 void main() 4287 { 4288 out0 = VAL; 4289 ${OUTPUT} 4290 } 4291 "" 4292 end 4293 4294 case mul_vs_not 4295 version 300 es 4296 values { output float out0 = 1.0; } 4297 both "" 4298 #version 300 es 4299 #if ( 8 * ! 0 ) == 8 4300 #define VAL 1.0 4301 #else 4302 #define VAL 0.0 4303 #endif 4304 4305 precision mediump float; 4306 ${DECLARATIONS} 4307 void main() 4308 { 4309 out0 = VAL; 4310 ${OUTPUT} 4311 } 4312 "" 4313 end 4314 4315 case modulo_vs_bit_invert 4316 version 300 es 4317 values { output float out0 = 1.0; } 4318 both "" 4319 #version 300 es 4320 #if ( 8 % ~ 4 ) == 3 4321 #define VAL 1.0 4322 #else 4323 #define VAL 0.0 4324 #endif 4325 4326 precision mediump float; 4327 ${DECLARATIONS} 4328 void main() 4329 { 4330 out0 = VAL; 4331 ${OUTPUT} 4332 } 4333 "" 4334 end 4335 4336 case modulo_vs_minus 4337 version 300 es 4338 values { output float out0 = 1.0; } 4339 both "" 4340 #version 300 es 4341 #if ( 8 % - 2 ) == 0 4342 #define VAL 1.0 4343 #else 4344 #define VAL 0.0 4345 #endif 4346 4347 precision mediump float; 4348 ${DECLARATIONS} 4349 void main() 4350 { 4351 out0 = VAL; 4352 ${OUTPUT} 4353 } 4354 "" 4355 end 4356 4357 case modulo_vs_plus 4358 version 300 es 4359 values { output float out0 = 1.0; } 4360 both "" 4361 #version 300 es 4362 #if ( 8 % + 2 ) == 0 4363 #define VAL 1.0 4364 #else 4365 #define VAL 0.0 4366 #endif 4367 4368 precision mediump float; 4369 ${DECLARATIONS} 4370 void main() 4371 { 4372 out0 = VAL; 4373 ${OUTPUT} 4374 } 4375 "" 4376 end 4377 4378 case div_vs_bit_invert 4379 version 300 es 4380 values { output float out0 = 1.0; } 4381 both "" 4382 #version 300 es 4383 #if ( 8 / ~ 2 ) == -2 4384 #define VAL 1.0 4385 #else 4386 #define VAL 0.0 4387 #endif 4388 4389 precision mediump float; 4390 ${DECLARATIONS} 4391 void main() 4392 { 4393 out0 = VAL; 4394 ${OUTPUT} 4395 } 4396 "" 4397 end 4398 4399 case div_vs_minus 4400 version 300 es 4401 values { output float out0 = 1.0; } 4402 both "" 4403 #version 300 es 4404 #if ( 8 / - 2 ) == -4 4405 #define VAL 1.0 4406 #else 4407 #define VAL 0.0 4408 #endif 4409 4410 precision mediump float; 4411 ${DECLARATIONS} 4412 void main() 4413 { 4414 out0 = VAL; 4415 ${OUTPUT} 4416 } 4417 "" 4418 end 4419 4420 case div_vs_plus 4421 version 300 es 4422 values { output float out0 = 1.0; } 4423 both "" 4424 #version 300 es 4425 #if ( 8 / + 2 ) == 4 4426 #define VAL 1.0 4427 #else 4428 #define VAL 0.0 4429 #endif 4430 4431 precision mediump float; 4432 ${DECLARATIONS} 4433 void main() 4434 { 4435 out0 = VAL; 4436 ${OUTPUT} 4437 } 4438 "" 4439 end 4440 4441 case mul_vs_bit_invert 4442 version 300 es 4443 values { output float out0 = 1.0; } 4444 both "" 4445 #version 300 es 4446 #if ( 8 * ~ 2 ) == -24 4447 #define VAL 1.0 4448 #else 4449 #define VAL 0.0 4450 #endif 4451 4452 precision mediump float; 4453 ${DECLARATIONS} 4454 void main() 4455 { 4456 out0 = VAL; 4457 ${OUTPUT} 4458 } 4459 "" 4460 end 4461 4462 case mul_vs_minus 4463 version 300 es 4464 values { output float out0 = 1.0; } 4465 both "" 4466 #version 300 es 4467 #if ( 8 * - 2 ) == -16 4468 #define VAL 1.0 4469 #else 4470 #define VAL 0.0 4471 #endif 4472 4473 precision mediump float; 4474 ${DECLARATIONS} 4475 void main() 4476 { 4477 out0 = VAL; 4478 ${OUTPUT} 4479 } 4480 "" 4481 end 4482 4483 case mul_vs_plus 4484 version 300 es 4485 values { output float out0 = 1.0; } 4486 both "" 4487 #version 300 es 4488 #if ( 8 * + 2 ) == 16 4489 #define VAL 1.0 4490 #else 4491 #define VAL 0.0 4492 #endif 4493 4494 precision mediump float; 4495 ${DECLARATIONS} 4496 void main() 4497 { 4498 out0 = VAL; 4499 ${OUTPUT} 4500 } 4501 "" 4502 end 4503 4504 case sub_vs_modulo 4505 version 300 es 4506 values { output float out0 = 1.0; } 4507 both "" 4508 #version 300 es 4509 #if ( 8 - 3 % 2 ) == 7 4510 #define VAL 1.0 4511 #else 4512 #define VAL 0.0 4513 #endif 4514 4515 precision mediump float; 4516 ${DECLARATIONS} 4517 void main() 4518 { 4519 out0 = VAL; 4520 ${OUTPUT} 4521 } 4522 "" 4523 end 4524 4525 case sub_vs_div 4526 version 300 es 4527 values { output float out0 = 1.0; } 4528 both "" 4529 #version 300 es 4530 #if ( 8 - 3 / 2 ) == 7 4531 #define VAL 1.0 4532 #else 4533 #define VAL 0.0 4534 #endif 4535 4536 precision mediump float; 4537 ${DECLARATIONS} 4538 void main() 4539 { 4540 out0 = VAL; 4541 ${OUTPUT} 4542 } 4543 "" 4544 end 4545 4546 case sub_vs_mul 4547 version 300 es 4548 values { output float out0 = 1.0; } 4549 both "" 4550 #version 300 es 4551 #if ( 8 - 3 * 2 ) == 2 4552 #define VAL 1.0 4553 #else 4554 #define VAL 0.0 4555 #endif 4556 4557 precision mediump float; 4558 ${DECLARATIONS} 4559 void main() 4560 { 4561 out0 = VAL; 4562 ${OUTPUT} 4563 } 4564 "" 4565 end 4566 4567 case add_vs_modulo 4568 version 300 es 4569 values { output float out0 = 1.0; } 4570 both "" 4571 #version 300 es 4572 #if ( 8 + 3 % 2 ) == 9 4573 #define VAL 1.0 4574 #else 4575 #define VAL 0.0 4576 #endif 4577 4578 precision mediump float; 4579 ${DECLARATIONS} 4580 void main() 4581 { 4582 out0 = VAL; 4583 ${OUTPUT} 4584 } 4585 "" 4586 end 4587 4588 case add_vs_div 4589 version 300 es 4590 values { output float out0 = 1.0; } 4591 both "" 4592 #version 300 es 4593 #if ( 8 + 3 / 2 ) == 9 4594 #define VAL 1.0 4595 #else 4596 #define VAL 0.0 4597 #endif 4598 4599 precision mediump float; 4600 ${DECLARATIONS} 4601 void main() 4602 { 4603 out0 = VAL; 4604 ${OUTPUT} 4605 } 4606 "" 4607 end 4608 4609 case add_vs_mul 4610 version 300 es 4611 values { output float out0 = 1.0; } 4612 both "" 4613 #version 300 es 4614 #if ( 8 + 3 * 2 ) == 14 4615 #define VAL 1.0 4616 #else 4617 #define VAL 0.0 4618 #endif 4619 4620 precision mediump float; 4621 ${DECLARATIONS} 4622 void main() 4623 { 4624 out0 = VAL; 4625 ${OUTPUT} 4626 } 4627 "" 4628 end 4629 4630 case rshift_vs_sub 4631 version 300 es 4632 values { output float out0 = 1.0; } 4633 both "" 4634 #version 300 es 4635 #if ( 8 >> 3 - 2 ) == 4 4636 #define VAL 1.0 4637 #else 4638 #define VAL 0.0 4639 #endif 4640 4641 precision mediump float; 4642 ${DECLARATIONS} 4643 void main() 4644 { 4645 out0 = VAL; 4646 ${OUTPUT} 4647 } 4648 "" 4649 end 4650 4651 case rshift_vs_add 4652 version 300 es 4653 values { output float out0 = 1.0; } 4654 both "" 4655 #version 300 es 4656 #if ( 8 >> 3 + 2 ) == 0 4657 #define VAL 1.0 4658 #else 4659 #define VAL 0.0 4660 #endif 4661 4662 precision mediump float; 4663 ${DECLARATIONS} 4664 void main() 4665 { 4666 out0 = VAL; 4667 ${OUTPUT} 4668 } 4669 "" 4670 end 4671 4672 case lshift_vs_sub 4673 version 300 es 4674 values { output float out0 = 1.0; } 4675 both "" 4676 #version 300 es 4677 #if ( 8 << 3 - 2 ) == 16 4678 #define VAL 1.0 4679 #else 4680 #define VAL 0.0 4681 #endif 4682 4683 precision mediump float; 4684 ${DECLARATIONS} 4685 void main() 4686 { 4687 out0 = VAL; 4688 ${OUTPUT} 4689 } 4690 "" 4691 end 4692 4693 case lshift_vs_add 4694 version 300 es 4695 values { output float out0 = 1.0; } 4696 both "" 4697 #version 300 es 4698 #if ( 8 << 3 + 2 ) == 256 4699 #define VAL 1.0 4700 #else 4701 #define VAL 0.0 4702 #endif 4703 4704 precision mediump float; 4705 ${DECLARATIONS} 4706 void main() 4707 { 4708 out0 = VAL; 4709 ${OUTPUT} 4710 } 4711 "" 4712 end 4713 4714 case greater_or_equal_vs_rshift 4715 version 300 es 4716 values { output float out0 = 1.0; } 4717 both "" 4718 #version 300 es 4719 #if ( 8 >= 3 >> 2 ) == 1 4720 #define VAL 1.0 4721 #else 4722 #define VAL 0.0 4723 #endif 4724 4725 precision mediump float; 4726 ${DECLARATIONS} 4727 void main() 4728 { 4729 out0 = VAL; 4730 ${OUTPUT} 4731 } 4732 "" 4733 end 4734 4735 case greater_or_equal_vs_lshift 4736 version 300 es 4737 values { output float out0 = 1.0; } 4738 both "" 4739 #version 300 es 4740 #if ( 8 >= 3 << 2 ) == 0 4741 #define VAL 1.0 4742 #else 4743 #define VAL 0.0 4744 #endif 4745 4746 precision mediump float; 4747 ${DECLARATIONS} 4748 void main() 4749 { 4750 out0 = VAL; 4751 ${OUTPUT} 4752 } 4753 "" 4754 end 4755 4756 case less_or_equal_vs_rshift 4757 version 300 es 4758 values { output float out0 = 1.0; } 4759 both "" 4760 #version 300 es 4761 #if ( 8 <= 3 >> 2 ) == 0 4762 #define VAL 1.0 4763 #else 4764 #define VAL 0.0 4765 #endif 4766 4767 precision mediump float; 4768 ${DECLARATIONS} 4769 void main() 4770 { 4771 out0 = VAL; 4772 ${OUTPUT} 4773 } 4774 "" 4775 end 4776 4777 case less_or_equal_vs_lshift 4778 version 300 es 4779 values { output float out0 = 1.0; } 4780 both "" 4781 #version 300 es 4782 #if ( 8 <= 3 << 2 ) == 1 4783 #define VAL 1.0 4784 #else 4785 #define VAL 0.0 4786 #endif 4787 4788 precision mediump float; 4789 ${DECLARATIONS} 4790 void main() 4791 { 4792 out0 = VAL; 4793 ${OUTPUT} 4794 } 4795 "" 4796 end 4797 4798 case greater_vs_rshift 4799 version 300 es 4800 values { output float out0 = 1.0; } 4801 both "" 4802 #version 300 es 4803 #if ( 8 > 3 >> 2 ) == 1 4804 #define VAL 1.0 4805 #else 4806 #define VAL 0.0 4807 #endif 4808 4809 precision mediump float; 4810 ${DECLARATIONS} 4811 void main() 4812 { 4813 out0 = VAL; 4814 ${OUTPUT} 4815 } 4816 "" 4817 end 4818 4819 case greater_vs_lshift 4820 version 300 es 4821 values { output float out0 = 1.0; } 4822 both "" 4823 #version 300 es 4824 #if ( 8 > 3 << 2 ) == 0 4825 #define VAL 1.0 4826 #else 4827 #define VAL 0.0 4828 #endif 4829 4830 precision mediump float; 4831 ${DECLARATIONS} 4832 void main() 4833 { 4834 out0 = VAL; 4835 ${OUTPUT} 4836 } 4837 "" 4838 end 4839 4840 case less_vs_rshift 4841 version 300 es 4842 values { output float out0 = 1.0; } 4843 both "" 4844 #version 300 es 4845 #if ( 8 < 3 >> 2 ) == 0 4846 #define VAL 1.0 4847 #else 4848 #define VAL 0.0 4849 #endif 4850 4851 precision mediump float; 4852 ${DECLARATIONS} 4853 void main() 4854 { 4855 out0 = VAL; 4856 ${OUTPUT} 4857 } 4858 "" 4859 end 4860 4861 case less_vs_lshift 4862 version 300 es 4863 values { output float out0 = 1.0; } 4864 both "" 4865 #version 300 es 4866 #if ( 8 < 3 << 2 ) == 1 4867 #define VAL 1.0 4868 #else 4869 #define VAL 0.0 4870 #endif 4871 4872 precision mediump float; 4873 ${DECLARATIONS} 4874 void main() 4875 { 4876 out0 = VAL; 4877 ${OUTPUT} 4878 } 4879 "" 4880 end 4881 4882 case not_equal_vs_greater_or_equal 4883 version 300 es 4884 values { output float out0 = 1.0; } 4885 both "" 4886 #version 300 es 4887 #if ( 8 != 3 >= 2 ) == 1 4888 #define VAL 1.0 4889 #else 4890 #define VAL 0.0 4891 #endif 4892 4893 precision mediump float; 4894 ${DECLARATIONS} 4895 void main() 4896 { 4897 out0 = VAL; 4898 ${OUTPUT} 4899 } 4900 "" 4901 end 4902 4903 case not_equal_vs_less_or_equal 4904 version 300 es 4905 values { output float out0 = 1.0; } 4906 both "" 4907 #version 300 es 4908 #if ( 8 != 3 <= 2 ) == 1 4909 #define VAL 1.0 4910 #else 4911 #define VAL 0.0 4912 #endif 4913 4914 precision mediump float; 4915 ${DECLARATIONS} 4916 void main() 4917 { 4918 out0 = VAL; 4919 ${OUTPUT} 4920 } 4921 "" 4922 end 4923 4924 case not_equal_vs_greater 4925 version 300 es 4926 values { output float out0 = 1.0; } 4927 both "" 4928 #version 300 es 4929 #if ( 8 != 3 > 2 ) == 1 4930 #define VAL 1.0 4931 #else 4932 #define VAL 0.0 4933 #endif 4934 4935 precision mediump float; 4936 ${DECLARATIONS} 4937 void main() 4938 { 4939 out0 = VAL; 4940 ${OUTPUT} 4941 } 4942 "" 4943 end 4944 4945 case not_equal_vs_less 4946 version 300 es 4947 values { output float out0 = 1.0; } 4948 both "" 4949 #version 300 es 4950 #if ( 8 != 3 < 2 ) == 1 4951 #define VAL 1.0 4952 #else 4953 #define VAL 0.0 4954 #endif 4955 4956 precision mediump float; 4957 ${DECLARATIONS} 4958 void main() 4959 { 4960 out0 = VAL; 4961 ${OUTPUT} 4962 } 4963 "" 4964 end 4965 4966 case equal_vs_greater_or_equal 4967 version 300 es 4968 values { output float out0 = 1.0; } 4969 both "" 4970 #version 300 es 4971 #if ( 8 == 3 >= 2 ) == 0 4972 #define VAL 1.0 4973 #else 4974 #define VAL 0.0 4975 #endif 4976 4977 precision mediump float; 4978 ${DECLARATIONS} 4979 void main() 4980 { 4981 out0 = VAL; 4982 ${OUTPUT} 4983 } 4984 "" 4985 end 4986 4987 case equal_vs_less_or_equal 4988 version 300 es 4989 values { output float out0 = 1.0; } 4990 both "" 4991 #version 300 es 4992 #if ( 8 == 3 <= 2 ) == 0 4993 #define VAL 1.0 4994 #else 4995 #define VAL 0.0 4996 #endif 4997 4998 precision mediump float; 4999 ${DECLARATIONS} 5000 void main() 5001 { 5002 out0 = VAL; 5003 ${OUTPUT} 5004 } 5005 "" 5006 end 5007 5008 case equal_vs_greater 5009 version 300 es 5010 values { output float out0 = 1.0; } 5011 both "" 5012 #version 300 es 5013 #if ( 8 == 3 > 2 ) == 0 5014 #define VAL 1.0 5015 #else 5016 #define VAL 0.0 5017 #endif 5018 5019 precision mediump float; 5020 ${DECLARATIONS} 5021 void main() 5022 { 5023 out0 = VAL; 5024 ${OUTPUT} 5025 } 5026 "" 5027 end 5028 5029 case equal_vs_less 5030 version 300 es 5031 values { output float out0 = 1.0; } 5032 both "" 5033 #version 300 es 5034 #if ( 8 == 3 < 2 ) == 0 5035 #define VAL 1.0 5036 #else 5037 #define VAL 0.0 5038 #endif 5039 5040 precision mediump float; 5041 ${DECLARATIONS} 5042 void main() 5043 { 5044 out0 = VAL; 5045 ${OUTPUT} 5046 } 5047 "" 5048 end 5049 5050 case bitwise_and_vs_not_equal 5051 version 300 es 5052 values { output float out0 = 1.0; } 5053 both "" 5054 #version 300 es 5055 #if ( 8 & 3 != 2 ) == 0 5056 #define VAL 1.0 5057 #else 5058 #define VAL 0.0 5059 #endif 5060 5061 precision mediump float; 5062 ${DECLARATIONS} 5063 void main() 5064 { 5065 out0 = VAL; 5066 ${OUTPUT} 5067 } 5068 "" 5069 end 5070 5071 case bitwise_and_vs_equal 5072 version 300 es 5073 values { output float out0 = 1.0; } 5074 both "" 5075 #version 300 es 5076 #if ( 8 & 3 == 2 ) == 0 5077 #define VAL 1.0 5078 #else 5079 #define VAL 0.0 5080 #endif 5081 5082 precision mediump float; 5083 ${DECLARATIONS} 5084 void main() 5085 { 5086 out0 = VAL; 5087 ${OUTPUT} 5088 } 5089 "" 5090 end 5091 5092 case xor_vs_bitwise_and 5093 version 300 es 5094 values { output float out0 = 1.0; } 5095 both "" 5096 #version 300 es 5097 #if ( 8 ^ 3 & 2 ) == 10 5098 #define VAL 1.0 5099 #else 5100 #define VAL 0.0 5101 #endif 5102 5103 precision mediump float; 5104 ${DECLARATIONS} 5105 void main() 5106 { 5107 out0 = VAL; 5108 ${OUTPUT} 5109 } 5110 "" 5111 end 5112 5113 case bitwise_or_vs_xor 5114 version 300 es 5115 values { output float out0 = 1.0; } 5116 both "" 5117 #version 300 es 5118 #if ( 8 | 3 ^ 2 ) == 9 5119 #define VAL 1.0 5120 #else 5121 #define VAL 0.0 5122 #endif 5123 5124 precision mediump float; 5125 ${DECLARATIONS} 5126 void main() 5127 { 5128 out0 = VAL; 5129 ${OUTPUT} 5130 } 5131 "" 5132 end 5133 5134 case logical_and_vs_bitwise_or 5135 version 300 es 5136 values { output float out0 = 1.0; } 5137 both "" 5138 #version 300 es 5139 #if ( 0 && 3 | 2 ) 5140 #define VAL 0.0 5141 #else 5142 #define VAL 1.0 5143 #endif 5144 5145 precision mediump float; 5146 ${DECLARATIONS} 5147 void main() 5148 { 5149 out0 = VAL; 5150 ${OUTPUT} 5151 } 5152 "" 5153 end 5154 5155 case logical_and_vs_bitwise_and 5156 version 300 es 5157 values { output float out0 = 1.0; } 5158 both "" 5159 #version 300 es 5160 #if ( 0 && 4 & 2 ) 5161 #define VAL 0.0 5162 #else 5163 #define VAL 1.0 5164 #endif 5165 5166 precision mediump float; 5167 ${DECLARATIONS} 5168 void main() 5169 { 5170 out0 = VAL; 5171 ${OUTPUT} 5172 } 5173 "" 5174 end 5175 5176 case logical_or_vs_logical_and 5177 version 300 es 5178 values { output float out0 = 1.0; } 5179 both "" 5180 #version 300 es 5181 #if ( 0 || 4 && 0 ) 5182 #define VAL 0.0 5183 #else 5184 #define VAL 1.0 5185 #endif 5186 5187 precision mediump float; 5188 ${DECLARATIONS} 5189 void main() 5190 { 5191 out0 = VAL; 5192 ${OUTPUT} 5193 } 5194 "" 5195 end 5196 5197end # operator_precedence 5198