3 import flash.display.MovieClip
6 function f() {return new Array(1,2,3);}
8 public class Main extends flash.display.MovieClip {
13 trace("ok "+count+"/"+num);
15 trace("error "+count+"/"+num);
19 function compare(x,y) {
23 var a:Array = new Array(1,2,3);
25 function f() {return a;}
26 function g() {return b;}
31 // test that ., [], (), @, ::, .. {x:y}, new all have the same precedence
34 compare(this.f()[2] , (((this).f)())[2])
35 //compare(new C.f()[1],2); //breaks
36 compare(new C().f()[1],2);
38 // test that ., [], () have higher precedence than ++, --, -, ~, !, delete, typeof
39 // TODO: @, delete, typeof
42 this.i++;compare(this.i,1);compare(i,5);
43 ++(this.a)[2]; compare(this.a[2],4);
44 delete this.f()[0];compare(String(this.a[0]), "undefined");
46 // test that ++ has higher precedence than unary -,~,!
51 // test that * / % have the same precedence
54 // test that ++,--,~ have higher precedence than * / %
55 i = 0;j = 1;compare(++i*j++, 1)
56 i = 0;j = 1;compare(++i/j++, 1)
57 i = 2;j = 2;compare(++i%j++, 1)
58 compare( (~1*2) & 1, 0);
60 // test that +,- have lower precedence than * / %
66 // test that +, - have higher precedence than >>,<<,>>>
74 // test that >>,<< have higher precedence than <,>,<=,>=,==
75 compare(3 < 1<<2, true)
76 compare(4 <= 1<<2, true)
77 compare(2 > 8>>3, true)
78 compare(1 >= 8>>3, true)
79 compare(1 == 1<<0, true)
80 compare(1 == 1>>0, true)
82 // test that <,>,<=,>= have higher precedence than as, in
83 compare(1<2 as Boolean, true)
84 //compare(1<2 in [true,true,true], true)
86 // test that as,in have higher precedence than ==,!=
87 compare(1==1 as Boolean, false);
88 compare(1!=1 as Boolean, true);
89 compare(false == true is Boolean, false);
90 compare(true != true is Boolean, false);
92 // test that >,<,>=,<= have higher precedence than ==, !=, ===, !==
93 compare(true == 3<4, true)
94 compare(true != 3>4, true)
95 compare(true === 3<=4, true)
96 compare(true !== 3>=4, true)
98 // test that ==,!= have higher precedence than &
102 // test that & has higher precedence than ^
105 // test that ^ has higher precedence than |
108 // test that | has higher precedence than &&
109 compare(false && 0|5, false)
111 // test that && has higher precedence than ||
112 compare(false && true || true, true)
114 // test that || has higher precedence than ?:
115 compare(true || false?11:0, 11)
117 // test that ?: and = have same precedence
119 var x = false ? y=3 : y=4;
124 // test that = is right-associative
129 // test that = has higher precedence than +=,-=,*=,/=,%=
134 // test that +=,-=,*=,/=,%=,>>=,<<=,>>>= all have the same associativity
135 // TODO: %=,/=,-=,>>=,<<=,>>>=
138 assert(x==14 && y==7);
140 // test that , has lower precedence than +=