added additional tests
authorkramm <kramm>
Tue, 30 Dec 2008 22:33:46 +0000 (22:33 +0000)
committerkramm <kramm>
Tue, 30 Dec 2008 22:33:46 +0000 (22:33 +0000)
35 files changed:
lib/as3/err/final.as [new file with mode: 0644]
lib/as3/err/final2.as [new file with mode: 0644]
lib/as3/err/interface.as [new file with mode: 0644]
lib/as3/err/interface2.as [new file with mode: 0644]
lib/as3/err/interface3.as [new file with mode: 0644]
lib/as3/err/interface4.as [new file with mode: 0644]
lib/as3/err/missingoverride.as [new file with mode: 0644]
lib/as3/err/override.as [new file with mode: 0644]
lib/as3/err/private.as [new file with mode: 0644]
lib/as3/err/staticinherit.as [new file with mode: 0644]
lib/as3/err/super.as [new file with mode: 0644]
lib/as3/ok/anonymous_functions.as [new file with mode: 0644]
lib/as3/ok/break-label.as [new file with mode: 0644]
lib/as3/ok/constructorfunc.as [new file with mode: 0644]
lib/as3/ok/continue.as [new file with mode: 0644]
lib/as3/ok/defaultvalue.as [new file with mode: 0644]
lib/as3/ok/delete.as [new file with mode: 0644]
lib/as3/ok/dynamicobj.as [new file with mode: 0644]
lib/as3/ok/extendinterface.as [new file with mode: 0644]
lib/as3/ok/extends.as [new file with mode: 0644]
lib/as3/ok/float.as [new file with mode: 0644]
lib/as3/ok/for-in.as [new file with mode: 0644]
lib/as3/ok/globalfunction.as [new file with mode: 0644]
lib/as3/ok/in.as [new file with mode: 0644]
lib/as3/ok/nested_functions.as [new file with mode: 0644]
lib/as3/ok/nopackage.as [new file with mode: 0644]
lib/as3/ok/ops.as [new file with mode: 0644]
lib/as3/ok/precedence.as [new file with mode: 0644]
lib/as3/ok/prototype.as [new file with mode: 0644]
lib/as3/ok/recursion.as [new file with mode: 0644]
lib/as3/ok/super.as [new file with mode: 0644]
lib/as3/ok/trycatch.as [new file with mode: 0644]
lib/as3/ok/typecast.as [new file with mode: 0644]
lib/as3/ok/unnamed_package.as [new file with mode: 0644]
lib/as3/ok/with.as [new file with mode: 0644]

diff --git a/lib/as3/err/final.as b/lib/as3/err/final.as
new file mode 100644 (file)
index 0000000..f4fe6eb
--- /dev/null
@@ -0,0 +1,11 @@
+package {
+    final class A {
+        function A() {
+        }
+    }
+  
+   //error: A is final:
+    public class Main extends A
+    {
+    }
+}
diff --git a/lib/as3/err/final2.as b/lib/as3/err/final2.as
new file mode 100644 (file)
index 0000000..77ea5eb
--- /dev/null
@@ -0,0 +1,13 @@
+package {
+    class A {
+        final public function f() {
+        }
+    }
+  
+    public class Main extends A
+    {
+        //error: f is final:
+        override public function f() {
+        }
+    }
+}
diff --git a/lib/as3/err/interface.as b/lib/as3/err/interface.as
new file mode 100644 (file)
index 0000000..501c4b1
--- /dev/null
@@ -0,0 +1,6 @@
+package I {
+    public interface I1 {
+        // access modifiers not allowed
+        private function f()
+    }
+}
diff --git a/lib/as3/err/interface2.as b/lib/as3/err/interface2.as
new file mode 100644 (file)
index 0000000..db79b7e
--- /dev/null
@@ -0,0 +1,7 @@
+package I {
+    public interface I1 {
+        function f() {
+            trace("..."); // method body not allowed
+        }
+    }
+}
diff --git a/lib/as3/err/interface3.as b/lib/as3/err/interface3.as
new file mode 100644 (file)
index 0000000..1427b47
--- /dev/null
@@ -0,0 +1,5 @@
+package I {
+    public interface I1 {
+        var x; // variable declaration not allowed
+    }
+}
diff --git a/lib/as3/err/interface4.as b/lib/as3/err/interface4.as
new file mode 100644 (file)
index 0000000..ef45f4e
--- /dev/null
@@ -0,0 +1,9 @@
+package I {
+    class D {
+    }
+
+    //error: can only implement interfaces, not classes
+    class C implements D 
+    {
+    }
+}
diff --git a/lib/as3/err/missingoverride.as b/lib/as3/err/missingoverride.as
new file mode 100644 (file)
index 0000000..3f1c8f5
--- /dev/null
@@ -0,0 +1,10 @@
+package I {
+    public interface I1 {
+        function f1()
+        function f2()
+    }
+    public class C {
+        function f1() {}
+        //fail to override f2
+    }
+}
diff --git a/lib/as3/err/override.as b/lib/as3/err/override.as
new file mode 100644 (file)
index 0000000..9dd18f7
--- /dev/null
@@ -0,0 +1,10 @@
+package p {
+    internal class C {
+        protected function e() {
+        }
+    }
+    public class D extends C {
+        protected function e() {
+        }
+    }
+}
diff --git a/lib/as3/err/private.as b/lib/as3/err/private.as
new file mode 100644 (file)
index 0000000..d71c903
--- /dev/null
@@ -0,0 +1,12 @@
+
+package p {
+    internal class C {
+        private function e() {
+        }
+    }
+    public class D extends C {
+        protected function f() {
+            super.e();
+        }
+    }
+}
diff --git a/lib/as3/err/staticinherit.as b/lib/as3/err/staticinherit.as
new file mode 100644 (file)
index 0000000..c7c43fb
--- /dev/null
@@ -0,0 +1,13 @@
+package package1 {
+    public class A {
+        public static function f() 
+        {
+        }
+    }
+    public class B extends A {
+        public function g() 
+        {
+            super.f()
+        }
+    }
+}
diff --git a/lib/as3/err/super.as b/lib/as3/err/super.as
new file mode 100644 (file)
index 0000000..4df3eac
--- /dev/null
@@ -0,0 +1,17 @@
+package {
+    public class A {
+        function A() {
+        }
+    }
+    public class Main {
+        public var x;
+        public function f() {
+        }
+        function Main() {
+            this.x = 3; // error: access to instance variable before super()
+            this.f()
+            super();
+            super(); // error: super called twice
+        }
+    }
+}
diff --git a/lib/as3/ok/anonymous_functions.as b/lib/as3/ok/anonymous_functions.as
new file mode 100644 (file)
index 0000000..f8bbf94
--- /dev/null
@@ -0,0 +1,22 @@
+package {
+    import flash.display.MovieClip
+    import flash.geom.Point
+
+    public class Main extends flash.display.MovieClip {
+        
+        function run(f:Function, text:String) {
+            f(text);
+        }
+
+        public function Main() {
+            var log = function(text) {
+                trace(text);
+            }
+            log("ok 1/3");
+            var l = log;
+            l("ok 2/3");
+
+            run(function(text) {trace(text)}, "ok 3/3")
+        }
+    }
+}
diff --git a/lib/as3/ok/break-label.as b/lib/as3/ok/break-label.as
new file mode 100644 (file)
index 0000000..c189144
--- /dev/null
@@ -0,0 +1,36 @@
+package {
+    import flash.display.MovieClip
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            var i,j,k;
+
+            outerloop:
+            for(i=0;i<100;i++) {
+                for(j=0;j<100;j++) {
+                    for(k=0;k<100;k++) {
+                        trace("ok 1/2");
+                        break outerloop;
+                        trace("error");
+                    }
+                    trace("error");
+                }
+                trace("error");
+            }
+            
+            for(i=0;i<100;i++) {
+                midloop:
+                for(j=0;j<100;j++) {
+                    for(k=0;k<100;k++) {
+                        trace("ok 2/2");
+                        break midloop;
+                        trace("error");
+                    }
+                    trace("error");
+                }
+                break;
+                trace("error");
+            }
+        }
+    }
+}
+
diff --git a/lib/as3/ok/constructorfunc.as b/lib/as3/ok/constructorfunc.as
new file mode 100644 (file)
index 0000000..4a0a261
--- /dev/null
@@ -0,0 +1,28 @@
+package {
+    import flash.display.MovieClip;
+    
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            function FooBar(x,y) {
+                this.x = x;
+                this.y = y;
+                this.ok4 = "ok 4/5";
+                this.f1 = function() {
+                    trace(this.ok4);
+                }
+            };
+            FooBar.prototype.z = "ok 3/5";
+            FooBar.prototype.f2 = function () {
+                trace(this.ok5);
+            }
+                
+            var foobar = new FooBar("ok 1/5", "ok 2/5");
+            foobar.ok5 = "ok 5/5";
+            trace(foobar.x);
+            trace(foobar.y);
+            trace(foobar.z);
+            foobar.f1();
+            foobar.f2();
+        }
+    }
+}
diff --git a/lib/as3/ok/continue.as b/lib/as3/ok/continue.as
new file mode 100644 (file)
index 0000000..570abfb
--- /dev/null
@@ -0,0 +1,42 @@
+package {
+    import flash.display.MovieClip
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            var i:int;
+            
+            /* test for loop */
+            var j:int=0;
+            for(i=0;i<100;i++) {
+                j++;
+                if(i!=50)
+                    continue;
+                trace("ok 1/6");
+            }
+            if(j==100)
+                trace("ok 2/6");
+           
+            /* test while loop */
+            while(i++<200) {
+                j++;
+                if(i!=150)
+                    continue;
+                trace("ok 3/6");
+            }
+            if(j==200)
+                trace("ok 4/6");
+            
+            /* test do-while loop */
+            
+            do {
+                j++;
+                if(i!=250)
+                    continue;
+                trace("ok 5/6");
+            } while(i++<300);
+
+            if(j==300)
+                trace("ok 6/6");
+        }
+    }
+}
+
diff --git a/lib/as3/ok/defaultvalue.as b/lib/as3/ok/defaultvalue.as
new file mode 100644 (file)
index 0000000..68c56ec
--- /dev/null
@@ -0,0 +1,39 @@
+package {
+    import flash.display.MovieClip
+    public class Main extends flash.display.MovieClip {
+
+        var o; //undefined
+        var s:String; //null
+        var b:Boolean; //false
+        var i:int; //0
+        var u:uint; //0
+        var f:Number; //NaN
+        var m:Main; //null
+
+        public function Main() {
+            var o; //undefined
+            var s:String; //null
+            var b:Boolean; //false
+            var i:int; //0
+            var u:uint; //0
+            var f:Number; //NaN
+            var m:Main; //null
+
+            if(String(o)=="undefined") trace("ok 1/14");
+            if(s===null) trace("ok 2/14");
+            if(b===false) trace("ok 3/14");
+            if(i==0) trace("ok 4/14");
+            if(u==0) trace("ok 5/14");
+            if(String(f)=="NaN") trace("ok 6/14");
+            if(m===null) trace("ok 7/14");
+            
+            if(String(this.o)=="undefined") trace("ok 8/14");
+            if(this.s===null) trace("ok 9/14");
+            if(this.b===false) trace("ok 10/14");
+            if(this.i==0) trace("ok 11/14");
+            if(this.u==0) trace("ok 12/14");
+            if(String(this.f)=="NaN") trace("ok 13/14");
+            if(this.m===null) trace("ok 14/14");
+        }
+    }
+}
diff --git a/lib/as3/ok/delete.as b/lib/as3/ok/delete.as
new file mode 100644 (file)
index 0000000..c9b2482
--- /dev/null
@@ -0,0 +1,24 @@
+package {
+    import flash.display.MovieClip
+
+    class C {
+    }
+    public dynamic class Main extends flash.display.MovieClip {
+        function Main() {
+            this.xx = new C;
+            if(this.xx is C) trace("ok 1/5");
+            delete this.xx;
+            if(this.xx is C) trace("error");
+
+            var a:Array = [1,2,3,4];
+            delete a[2];
+            if(a[0]==1 &&
+               a[1]==2 &&
+               String(a[2])=="undefined" &&
+               a[3]==4) trace("ok 2/5");
+
+            //TODO: we can also delete from XML
+        }
+    }
+}
+
diff --git a/lib/as3/ok/dynamicobj.as b/lib/as3/ok/dynamicobj.as
new file mode 100644 (file)
index 0000000..ef7294d
--- /dev/null
@@ -0,0 +1,18 @@
+
+package {
+    import flash.display.MovieClip
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            var x:Object = 
+            {"one": 1,
+             "two": 2,
+             "three": 3,
+            };
+            if(x["two"]==2) trace("ok 1/2");
+
+            x.f = function() {trace("ok 2/2")};
+            x.f();
+        }
+    }
+}
+
diff --git a/lib/as3/ok/extendinterface.as b/lib/as3/ok/extendinterface.as
new file mode 100644 (file)
index 0000000..394a939
--- /dev/null
@@ -0,0 +1,25 @@
+package {
+    import flash.display.MovieClip
+    public interface I1 {
+        function f()
+    }
+    public interface I2 extends I1 {
+        function g()
+    }
+    public class C implements I2 {
+        public function f() {
+            trace("ok 1/2");
+        }
+        public function g() {
+            trace("ok 2/2");
+        }
+    }
+
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            var x:I2 = new C;
+            x.f();
+            x.g();
+        }
+    }
+}
diff --git a/lib/as3/ok/extends.as b/lib/as3/ok/extends.as
new file mode 100644 (file)
index 0000000..0ad7a49
--- /dev/null
@@ -0,0 +1,38 @@
+package p {
+    internal class C {
+        private function e() {
+            trace("err");
+        }
+        protected function f() {
+            trace("ok 1/5");
+        }
+    }
+    public class D extends C {
+        protected function e() {
+        }
+        override protected function f() {
+            super.f()
+        }
+    }
+}
+package {
+    public class X extends p.D {
+        function X() {
+            super.e();
+            f()
+        }
+    }
+    import flash.display.MovieClip
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            var x = new X
+            
+            import p.D
+            /* not sure what the difference between "is" and "instanceof" actually is */
+            if(x is X) trace("ok 2/5");
+            if(x is D) trace("ok 3/5");
+            if(x instanceof X) trace("ok 4/5");
+            if(x instanceof D) trace("ok 5/5");
+        }
+    }
+}
diff --git a/lib/as3/ok/float.as b/lib/as3/ok/float.as
new file mode 100644 (file)
index 0000000..76c1786
--- /dev/null
@@ -0,0 +1,9 @@
+package {
+    import flash.display.MovieClip
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            var x = .5;
+            if(x is Number) trace("ok");
+        }
+    }
+}
diff --git a/lib/as3/ok/for-in.as b/lib/as3/ok/for-in.as
new file mode 100644 (file)
index 0000000..cad7e7a
--- /dev/null
@@ -0,0 +1,34 @@
+package {
+    import flash.display.MovieClip
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            var a:Array = new Array(1,2,3,4,6,5,7,8,9,10);
+            var j:int = 0;
+            for(var x in a) {
+                j += x;
+            }
+            if(j==45) trace("ok 1/4");
+           
+            var y;
+            j = 0;
+            for(y in a) {
+                j += y;
+            }
+            if(j==45) trace("ok 2/4");
+            
+            j = 0;
+            for each(var x in a) {
+                j += x;
+            }
+            if(j==55) trace("ok 3/4");
+            
+            var y = 0;
+            j = 0;
+            for each(y in a) {
+                j += y;
+            }
+            if(j==55) trace("ok 4/4");
+        }
+    }
+}
+
diff --git a/lib/as3/ok/globalfunction.as b/lib/as3/ok/globalfunction.as
new file mode 100644 (file)
index 0000000..8f5fb44
--- /dev/null
@@ -0,0 +1,38 @@
+package package_A {
+
+    import flash.utils.setInterval;
+
+    internal class class_A {
+
+        function class_A() {
+            trace("ok 2/4")
+        }
+        internal function f() {
+            trace("ok 3/4");
+        }
+        static internal function g() {
+            trace("ok 4/4");
+        }
+    }
+
+    internal function i_A() {
+        trace("ok 1/4");
+        (new class_A).f()
+    }
+
+    public function p_A() {
+        i_A();
+        class_A.g()
+    }
+}
+
+package {
+    import flash.display.MovieClip
+    import package_A.p_A
+
+    public class Main extends flash.display.MovieClip {
+        public function Main() {
+            p_A()
+        }
+    }
+}
diff --git a/lib/as3/ok/in.as b/lib/as3/ok/in.as
new file mode 100644 (file)
index 0000000..49d1449
--- /dev/null
@@ -0,0 +1,40 @@
+package {
+    import flash.display.MovieClip;
+
+    public class C {
+        public var x;
+        public function y() {};
+        var e1;
+        function e2() {};
+
+        public static var s1;
+        public static function s2() {}
+    }
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            /* test "in" for arrays */
+            var a:Array = new Array(1,2,3,4);
+            if(3 in a) trace("ok 1/7");
+            if(5 in a) trace("error");
+            else       trace("ok 2/7");
+
+            /* test "in" for normal classes */
+            var c:C = new C;
+            if("x" in c) trace("ok 3/7");
+            if("y" in c) trace("ok 4/7");
+            if("e1" in c) trace("error"); // not public
+            if("e2" in c) trace("error"); // not public
+
+            /* test "in" for static members */
+            if("s1" in C) trace("ok 5/7");
+            if("s2" in C) trace("ok 6/7");
+
+            /* test "in" for dynamic objects */
+            var o:Object = new Object();
+            o["r"] = 1;
+            if("r" in o) trace("ok 7/7");
+            delete o["r"];
+            if("r" in o) trace("error");
+        }
+    }
+}
diff --git a/lib/as3/ok/nested_functions.as b/lib/as3/ok/nested_functions.as
new file mode 100644 (file)
index 0000000..28d5912
--- /dev/null
@@ -0,0 +1,33 @@
+package {
+    import flash.display.MovieClip
+    import flash.geom.Point
+
+    public class Main extends flash.display.MovieClip {
+        static public var ok:String = "ok";
+
+        public function Main() {
+            trace("ok 1/5")
+            var x = msg(2, 5)
+            var y = msg(3, 5)
+            trace(x);
+            trace(y);
+
+            function msg(nr,total):String {
+                return ""+this.Main.ok+" "+nr+"/"+total
+            }
+
+            var x1 = "err";
+            var x2 = "err";
+            
+            function setok() {
+                x1 = "ok 4/5";
+                x2 = "ok 5/5";
+            }
+            var s = setok;
+            s();
+            trace(x1);
+            trace(x2);
+
+        }
+    }
+}
diff --git a/lib/as3/ok/nopackage.as b/lib/as3/ok/nopackage.as
new file mode 100644 (file)
index 0000000..1821239
--- /dev/null
@@ -0,0 +1,22 @@
+/* functions which are valid for this source file only */
+
+function f1() {
+    trace("ok 1/3")
+};
+
+package {
+    import flash.display.MovieClip
+
+    public class Main extends flash.display.MovieClip {
+        public function Main() {
+            f1()
+            trace("ok 2/3")
+            f3()
+        }
+    }
+}
+
+function f3() {
+    trace("ok 3/3")
+};
+
diff --git a/lib/as3/ok/ops.as b/lib/as3/ok/ops.as
new file mode 100644 (file)
index 0000000..0471d5a
--- /dev/null
@@ -0,0 +1,88 @@
+
+package {
+    import flash.display.MovieClip
+    public class Main extends flash.display.MovieClip {
+        var count:int = 1;
+        var num:int = 27;
+        function assert(b:Boolean) {
+            if(b) {
+                trace("ok "+count+"/"+num);
+            } else {
+                trace("error "+count+"/"+num);
+            }
+            count = count + 1
+        }
+        function Main() {
+            /* operations not tested here:
+               * comparison is tested in compare.as
+               * 'as' and 'is' are tested in typecast.as and extends.as
+               * ++ and -- are tested in assignments.as
+               * 'in' is tested by in.as
+               * || and && are tested in boolvalue.as
+               * <op>= is tested in assignments.as
+            */
+
+            /* test unary minus */
+            assert(-(3) == -3);
+
+            /* test tenary operator */
+            assert((true?1:2) == 1);
+            true?assert(1):assert(0);
+            false?assert(0):assert(1);
+
+            /* test other operators */
+            trace("[arithmetric]");
+            assert(3*3==9);
+            assert(3/3==1);
+            assert(10%4==2);
+            assert(2+3==5);
+            assert(2-3==-1);
+
+            /* test not */
+            trace("[not]");
+            assert(!false);
+            
+            /* test strict equals/unequals */
+            trace("[strict equals]");
+            assert(3===3);
+            assert(3!==4);
+            assert(!(3===4));
+            assert(!(3!==3));
+
+            /* test bit operations */
+            trace("[bit operations]");
+            assert(!(0xaaaaaaaa & 0x55555555))
+            assert((0xaa | 0x55) == 0xff);
+            assert((0xff ^ 0x55) == 0xaa);
+            assert((1 & ~1) == 0);
+            assert((1|~1)==~0);
+           
+            /* test shift operations */
+            trace("[shift operations]");
+            assert((0xff<<8)==0xff00);
+            assert((0xff>>4)==0x0f);
+            assert((-1>>1)==-1);
+            assert((-1>>1)==-1);
+            assert((-1>>>1)>0);
+
+            /* test typeof */
+            trace("[typeof]");
+            assert(typeof(3)=="number" && 
+                   typeof("")=="string" &&
+                   typeof(this)=="object" &&
+                   typeof(undefined)=="undefined" &&
+                   typeof(null)=="object" &&
+                   typeof(assert)=="function" &&
+                   typeof(Main)=="object");
+            
+            /* test void */
+            trace("[void]");
+            var v = void;
+            assert(String(v)=="undefined");
+
+            /* test comma */
+            assert( (1,2,3,4) == 4);
+        }
+    }
+}
+
diff --git a/lib/as3/ok/precedence.as b/lib/as3/ok/precedence.as
new file mode 100644 (file)
index 0000000..3f145f5
--- /dev/null
@@ -0,0 +1,144 @@
+package {
+    
+    import flash.display.MovieClip
+
+    class C {
+        function f() {return new Array(1,2,3);}
+    }
+    public class Main extends flash.display.MovieClip {
+        var count:int = 1;
+        var num:int = 27;
+        function assert(b) {
+            if(b) {
+                trace("ok "+count+"/"+num);
+            } else {
+                trace("error "+count+"/"+num);
+            }
+            count = count + 1
+        }
+        function compare(x,y) {
+            assert(x==y);
+        }
+            
+        var a:Array = new Array(1,2,3);
+        var b:int=10;
+        function f() {return a;}
+        function g() {return b;}
+        var i=0;
+
+        function Main() {
+
+            // test that ., [], (), @, ::, .. {x:y}, new all have the same precedence
+            // TODO: @, ::, ..
+
+            compare(this.f()[2] , (((this).f)())[2])
+            //compare(new C.f()[1],2); //breaks
+            compare(new C().f()[1],2);
+
+            // test that ., [], () have higher precedence than ++, --, -, ~, !, delete, typeof
+            // TODO: @, delete, typeof
+            var i:int=5,j:int;
+            this.i=0;
+            this.i++;compare(this.i,1);compare(i,5);
+            ++(this.a)[2]; compare(this.a[2],4);
+            delete this.f()[0];compare(String(this.a[0]), "undefined");
+
+            // test that ++ has higher precedence than unary -,~,!
+            compare(-i++,-5);
+            compare(!i++,false);
+            compare(~i++,~7);
+
+            // test that * / % have the same precedence
+            compare(3*10/15%4, 2)
+            
+            // test that ++,--,~ have higher precedence than * / %
+            i = 0;j = 1;compare(++i*j++, 1)
+            i = 0;j = 1;compare(++i/j++, 1)
+            i = 2;j = 2;compare(++i%j++, 1)
+            compare( (~1*2) & 1, 0);
+
+            // test that +,- have lower precedence than * / %
+            compare(1+1*2, 3)
+            compare(5-4/2, 3)
+            compare(3-4%2, 3)
+            compare(2+1%2, 3)
+
+            // test that +, - have higher precedence than >>,<<,>>>
+            compare(4>>1+1, 1)
+            compare(4>>1-1, 4)
+            compare(4>>>1+1, 1)
+            compare(4>>>1-1, 4)
+            compare(1<<1+1, 4)
+            compare(4<<1-1, 4)
+            
+            // test that >>,<< have higher precedence than <,>,<=,>=,==
+            compare(3 < 1<<2, true)
+            compare(4 <= 1<<2, true)
+            compare(2 > 8>>3, true)
+            compare(1 >= 8>>3, true)
+            compare(1 == 1<<0, true)
+            compare(1 == 1>>0, true)
+            
+            // test that <,>,<=,>= have higher precedence than as, in
+            compare(1<2 as Boolean, true)
+            //compare(1<2 in [true,true,true], true)
+
+            // test that >,<,>=,<= have higher precedence than ==, !=, ===, !==
+            compare(true == 3<4, true)
+            compare(true != 3>4, true)
+            compare(true === 3<=4, true)
+            compare(true !== 3>=4, true)
+            
+            // test that ==,!= have higher precedence than &
+            compare(3&4==4, 1)
+            compare(3&0!=4, 1)
+
+            // test that & has higher precedence than ^
+            compare(1^1&4, 1)
+            
+            // test that ^ has higher precedence than |
+            compare(5|4^4, 5)
+            
+            // test that | has higher precedence than &&
+            compare(false && 0|5, false)
+            
+            // test that && has higher precedence than ||
+            compare(false && true || true, true)
+            
+            // test that || has higher precedence than ?:
+            compare(true || false?11:0, 11)
+            
+            // test that ?: and = have same precedence 
+            var y = 0;
+            var x = false ? y=3 : y=4;
+            compare(y,4)
+            false ? y=3 : y=5;
+            compare(y,5)
+            
+            // test that = is right-associative
+            x = y = 3;
+            compare(x,3)
+            compare(y,3)
+            
+            // test that = has higher precedence than +=,-=,*=,/=,%=
+            x=4;y=10;
+            x += y = 4;
+            compare(x,8);
+
+            // test that +=,-=,*=,/=,%=,>>=,<<=,>>>= all have the same associativity
+            // TODO: %=,/=,-=,>>=,<<=,>>>=
+            x=2;y=3;
+            x *= y += 4;
+            assert(x==14 && y==7);
+
+            // test that , has lower precedence than +=
+            x=0;
+            var v=0;
+            v += 3,4;
+            compare(v,3)
+
+        }
+
+    }
+}
+
diff --git a/lib/as3/ok/prototype.as b/lib/as3/ok/prototype.as
new file mode 100644 (file)
index 0000000..138b778
--- /dev/null
@@ -0,0 +1,21 @@
+package {
+    import flash.display.MovieClip;
+    
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            function MySuper() {
+                this.ok3="ok 3/3";
+            }
+            function MyClass(ok1,ok2) {
+                this.ok1 = ok1;
+                this.ok2 = ok2;
+            };
+            MyClass.prototype = new MySuper;
+
+            var m = new MyClass("ok 1/3", "ok 2/3");
+            trace(m.ok1);
+            trace(m.ok2);
+            trace(m.ok3);
+        }
+    }
+}
diff --git a/lib/as3/ok/recursion.as b/lib/as3/ok/recursion.as
new file mode 100644 (file)
index 0000000..bdf6fa8
--- /dev/null
@@ -0,0 +1,18 @@
+
+package {
+    import flash.display.MovieClip
+    import flash.geom.Point
+
+    public class Main extends flash.display.MovieClip {
+        
+        function write(nr) {
+            trace("ok "+nr+"/3");
+            if(nr<3)
+                write(nr+1);
+        }
+
+        public function Main() {
+            write(1);
+        }
+    }
+}
diff --git a/lib/as3/ok/super.as b/lib/as3/ok/super.as
new file mode 100644 (file)
index 0000000..12583ef
--- /dev/null
@@ -0,0 +1,30 @@
+package {
+    class C {
+        function C(s:String) {
+            trace(s);
+        }
+    }
+    class D extends C {
+        function D() {
+            //explicit super call w/ args
+            super("ok");
+        }
+    }
+    class E extends D {
+        function E() {
+            //explicit super call
+            super();
+        }
+    }
+    class F extends D {
+        function F() {
+            //implicit super call
+        }
+    }
+    import flash.display.MovieClip
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            new F
+        }
+    }
+}
diff --git a/lib/as3/ok/trycatch.as b/lib/as3/ok/trycatch.as
new file mode 100644 (file)
index 0000000..0a890b9
--- /dev/null
@@ -0,0 +1,52 @@
+package {
+    import flash.display.MovieClip;
+
+    public class MyError {
+    }
+    public class MyOtherError {
+        var ok5="ok 5/5";
+    }
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            try {
+                throw new MyError
+                trace("error");
+            } catch(error:Error) {
+                // MyError is not of the Error class
+                trace("error");
+            } catch(error:MyError) {
+                trace("ok 1/5");
+            } catch(x) {
+                trace("error");
+            }
+            
+            try {
+                throw new MyOtherError
+                trace("error");
+            } catch(error:MyError) {
+                trace("error");
+            } catch(x:*) { // ":*" is the same as ""
+                trace("ok 2/5");
+            }
+            
+            try {
+                trace("ok 3/5");
+                // don't throw any error
+            } catch(error:MyError) {
+                trace("error");
+            } catch(error:MyOtherError) {
+                trace("error");
+            } catch(x:*) { // ":*" is the same as ""
+                trace("error");
+            }
+
+            trace("ok 4/5");
+
+            try {throw new MyOtherError} 
+            catch(x:*) {
+                trace((x as MyOtherError).ok5);
+            }
+
+        }
+    }
+}
diff --git a/lib/as3/ok/typecast.as b/lib/as3/ok/typecast.as
new file mode 100644 (file)
index 0000000..66c2ffd
--- /dev/null
@@ -0,0 +1,36 @@
+package {
+    import flash.display.MovieClip
+    
+    public class C {
+        public function toString() {
+            return "ok 7/7";
+        }
+    }
+    
+    public class D extends C {
+    }
+    
+    public class E extends D {
+    }
+
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            var e = new E;
+            
+            if(e is E) trace("ok 1/7");
+            C(e);
+            var d:D = e as D;
+            if(e is E) trace("ok 2/7");
+            var c:C = C(e)
+            if(e is E) trace("ok 3/7");
+
+            var x = int(4.93);
+            if(x==4) trace("ok 4/7");
+
+            if(int(true)==1) trace("ok 5/7");
+            if(int(false)==0) trace("ok 6/7");
+
+            trace(String(new C)) //will call toString()
+        }
+    }
+}
diff --git a/lib/as3/ok/unnamed_package.as b/lib/as3/ok/unnamed_package.as
new file mode 100644 (file)
index 0000000..3806f09
--- /dev/null
@@ -0,0 +1,36 @@
+/* test whether variables and functions in the global package are accessible everywhere */
+
+package {
+    
+    public var ok1="ok 1/3";
+    internal var ok2="ok 2/3";
+    public var ok3="ok 3/3";
+
+    public function f() {
+        trace(ok2);
+    }
+    public class C {
+        function C() {
+            trace(ok3);
+        }
+    }
+
+}
+package package1 {
+    public function g() {
+        trace(ok1)
+        f()
+        new C
+    }
+}
+
+package {
+    import package1.g
+    import flash.display.MovieClip
+
+    public class Main extends flash.display.MovieClip {
+        public function Main() {
+            g()
+        }
+    }
+}
diff --git a/lib/as3/ok/with.as b/lib/as3/ok/with.as
new file mode 100644 (file)
index 0000000..4115257
--- /dev/null
@@ -0,0 +1,26 @@
+package {
+    import flash.display.MovieClip;
+    public class A {
+        var ok1 = "ok 1/4";
+        function ok2() {
+            trace("ok 2/4");
+        }
+        static var ok3="ok 3/4";
+        static function ok4() {
+            trace("ok 4/4");
+        }
+    }
+    public class Main extends flash.display.MovieClip {
+        function Main() {
+            var a:A = new A;
+            with(a) {
+                trace(ok1);
+                ok2();
+            }
+            with(A) {
+                trace(ok3);
+                ok4();
+            }
+        }
+    }
+}