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 >,<,>=,<= have higher precedence than ==, !=, ===, !==
87 compare(true == 3<4, true)
88 compare(true != 3>4, true)
89 compare(true === 3<=4, true)
90 compare(true !== 3>=4, true)
92 // test that ==,!= have higher precedence than &
96 // test that & has higher precedence than ^
99 // test that ^ has higher precedence than |
102 // test that | has higher precedence than &&
103 compare(false && 0|5, false)
105 // test that && has higher precedence than ||
106 compare(false && true || true, true)
108 // test that || has higher precedence than ?:
109 compare(true || false?11:0, 11)
111 // test that ?: and = have same precedence
113 var x = false ? y=3 : y=4;
118 // test that = is right-associative
123 // test that = has higher precedence than +=,-=,*=,/=,%=
128 // test that +=,-=,*=,/=,%=,>>=,<<=,>>>= all have the same associativity
129 // TODO: %=,/=,-=,>>=,<<=,>>>=
132 assert(x==14 && y==7);
134 // test that , has lower precedence than +=