gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r11117: Tests for class construction


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11117: Tests for class construction.
Date: Mon, 15 Jun 2009 19:56:19 +0200
User-agent: Bazaar (1.13.1)

------------------------------------------------------------
revno: 11117
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2009-06-15 19:56:19 +0200
message:
  Tests for class construction.
added:
  testsuite/as3/class.as
modified:
  testsuite/as3/Makefile.am
  testsuite/as3/basic.as
  testsuite/as3/check.as
  testsuite/as3/dejagnu.as
    ------------------------------------------------------------
    revno: 11112.1.19
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Mon 2009-06-15 18:42:47 +0200
    message:
      Make dejagnu class use static functions and vars so that it is less
      complicated.
    modified:
      testsuite/as3/basic.as
      testsuite/as3/check.as
      testsuite/as3/dejagnu.as
    ------------------------------------------------------------
    revno: 11112.1.20
    committer: Benjamin Wolsey <address@hidden>
    branch nick: test
    timestamp: Mon 2009-06-15 19:07:37 +0200
    message:
      Test some class construction.
    added:
      testsuite/as3/class.as
    modified:
      testsuite/as3/Makefile.am
=== modified file 'testsuite/as3/Makefile.am'
--- a/testsuite/as3/Makefile.am 2009-05-26 08:02:42 +0000
+++ b/testsuite/as3/Makefile.am 2009-06-15 17:07:37 +0000
@@ -28,6 +28,7 @@
 
 BOGUS_AS3TESTS = \
        basic.as \
+       class.as \
        $(NULL)
 
 AS3TESTS=$(SANE_AS3TESTS) $(BOGUS_AS3TESTS)

=== modified file 'testsuite/as3/basic.as'
--- a/testsuite/as3/basic.as    2009-03-31 09:02:23 +0000
+++ b/testsuite/as3/basic.as    2009-06-15 16:42:47 +0000
@@ -21,13 +21,11 @@
 
     import flash.display.MovieClip;
 
-
     public class Hello extends MovieClip {
 
         DEJAGNU_OBJ;
 
         public function Hello() {
-            INIT_DEJAGNU;    
 
             var i = 1;
             i++;

=== modified file 'testsuite/as3/check.as'
--- a/testsuite/as3/check.as    2009-03-24 10:18:08 +0000
+++ b/testsuite/as3/check.as    2009-06-15 16:42:47 +0000
@@ -22,33 +22,32 @@
 
 #include "dejagnu.as"
 
-#define DEJAGNU_OBJ import dejagnu.Dejagnu; \
-               var DJ:Dejagnu
-
-#define INIT_DEJAGNU DJ = new Dejagnu(this);
+#define DEJAGNU_OBJ import dejagnu.Dejagnu
 
 #define _INFO_ ' ['+__FILE__+':'+__LINE__+']'
 
-#define check_equals(a, b) DJ.check_equals(a, b, _INFO_, #a);
-
-#define xcheck_equals(a, b) DJ.xcheck_equals(a, b, _INFO_, #a);
-
-#define check(a) DJ.check(a, _INFO_);
-#define xcheck(a) DJ.xcheck(a, _INFO_);
-
-#define pass(text) DJ.pass(text + _INFO_)
-#define xpass(text) DJ.xpass(text + _INFO_)
-#define fail(text) DJ.fail(text + _INFO_)
-#define xfail(text) DJ.xfail(text + _INFO_)
-#define pass(text) DJ.pass(text + _INFO_)
-#define untested(text) DJ.untested(text + _INFO_)
-#define unresolved(text) DJ.unresolved(text + _INFO_)
-
-#define note(text) DJ.note(text + _INFO_);
-
-#define totals(x) DJ.totals(x, _INFO_)
-
-#define xtotals(x) DJ.xtotals(x, _INFO_)
+#define check_equals(a, b) Dejagnu.check_equals(a, b, _INFO_, #a);
+
+#define xcheck_equals(a, b) Dejagnu.xcheck_equals(a, b, _INFO_, #a);
+
+#define check(a) Dejagnu.check(a, _INFO_);
+#define xcheck(a) Dejagnu.xcheck(a, _INFO_);
+
+#define done() Dejagnu.done();
+
+#define pass(text) Dejagnu.pass(text + _INFO_)
+#define xpass(text) Dejagnu.xpass(text + _INFO_)
+#define fail(text) Dejagnu.fail(text + _INFO_)
+#define xfail(text) Dejagnu.xfail(text + _INFO_)
+#define pass(text) Dejagnu.pass(text + _INFO_)
+#define untested(text) Dejagnu.untested(text + _INFO_)
+#define unresolved(text) Dejagnu.unresolved(text + _INFO_)
+
+#define note(text) Dejagnu.note(text + _INFO_);
+
+#define totals(x) Dejagnu.totals(x, _INFO_)
+
+#define xtotals(x) Dejagnu.xtotals(x, _INFO_)
 
 #define _QUOTEME(x) #x
 #define QUOTEME(x) _QUOTEME(x)

=== added file 'testsuite/as3/class.as'
--- a/testsuite/as3/class.as    1970-01-01 00:00:00 +0000
+++ b/testsuite/as3/class.as    2009-06-15 17:07:37 +0000
@@ -0,0 +1,80 @@
+//
+//   Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+#include "check.as"
+
+package hello {
+
+    import flash.display.MovieClip;
+
+    public class S {
+        public static var s : String;
+    }
+
+    public class Base {
+        public function Base() {
+            trace("Base ctor");
+            S.s += "Base ";
+        }
+    }
+
+    public class Derived extends Base {
+        public function Derived() {
+            S.s += "Derived ";
+        }
+    }
+
+    public class Hello extends MovieClip {
+
+        DEJAGNU_OBJ;
+
+        public function Hello() {
+
+            check_equals(S, "[class S]");
+            check_equals(S.s, null);
+            check_equals(typeof(S.s), "object");
+
+            S.s = "Hello ";
+            check_equals(S.s, "Hello ");
+
+            check_equals(Base, "[class Base]");
+            check_equals(Derived, "[class Derived]");
+
+            var b1 : Base = new Base();
+            check(b1 instanceof Base);
+            check(!(b1 instanceof Derived));
+            check_equals(S.s, "Hello Base ");
+            
+            S.s = "";
+            var b2 : Base = new Derived();
+            check(b2 instanceof Base);
+            check(b2 instanceof Derived);
+            check_equals(S.s, "Base Derived ");
+
+            S.s = "";
+            var d1 : Derived = new Derived();
+            check(d1 instanceof Base);
+            check(d1 instanceof Derived);
+            check_equals(S.s, "Base Derived ");
+
+            totals(15);
+
+            done();
+        }
+    }
+}
+         

=== modified file 'testsuite/as3/dejagnu.as'
--- a/testsuite/as3/dejagnu.as  2009-03-24 10:18:08 +0000
+++ b/testsuite/as3/dejagnu.as  2009-06-15 16:42:47 +0000
@@ -23,52 +23,45 @@
 
     public class Dejagnu extends Sprite {
 
-        private var passed;
-        private var failed;
-        private var xpassed;
-        private var xfailed;
-        private var untest;
-        private var unresolve;
-        private var tf:TextField;
+        private static var passed = 0;
+        private static var failed = 0;
+        private static var xpassed = 0;
+        private static var xfailed = 0;
+        private static var untest = 0;
+        private static var unresolve = 0;
+        private static var tf:TextField = new TextField();
         
-        public function Dejagnu(o) {
-            passed = 0;
-            failed = 0;
-            xpassed = 0;
-            xfailed = 0;
-            untest = 0;
-            unresolve = 0;
-            tf = new TextField();
+        public static function Dejagnu(o) {
             tf.autoSize = TextFieldAutoSize.LEFT;
             addChild(tf);
             o.addChild(this);
         } 
        
-        public function fail (why) {
+        public static function fail (why) {
             failed++;
             var msg = 'FAILED: '+why;
             xtrace(msg);
         }
         
-        public function xfail(why) {
+        public static function xfail(why) {
             xfailed++;
             var msg = 'XFAILED: '+why;
             xtrace(msg);
         }
 
-        public function pass(why) {
+        public static function pass(why) {
             passed++;
             var msg = 'PASSED: '+why;
             trace (msg);
         }
 
-        public function xpass(why) {
+        public static function xpass(why) {
             xpassed++;
             var msg = 'XPASSED: '+why;
             trace (msg);
         }
 
-        public function totals(exp, msg) {
+        public static function totals(exp, msg) {
             var obt = testcount();
             if ( exp != undefined && obt != exp ) {
                 fail('Test run '+obt+' (expected '+exp+') ['+msg+']');
@@ -77,7 +70,7 @@
             }
         }
     
-        public function xtotals(exp, msg) {
+        public static function xtotals(exp, msg) {
             var obt = testcount();
             if ( exp != undefined && obt != exp ) {
                 xfail('Test run '+obt+' (expected '+exp+') ['+msg+']');
@@ -86,7 +79,7 @@
             }
         }
     
-        public function check_equals(obt, exp, msg, expression) {
+        public static function check_equals(obt, exp, msg, expression) {
             if (msg == null) msg = "";
             if (obt == exp) { 
                 pass(expression + ' == ' + exp + ' ' + msg);
@@ -97,7 +90,7 @@
             }
         }
     
-        public function xcheck_equals(obt, exp, msg, expression) {
+        public static function xcheck_equals(obt, exp, msg, expression) {
             if (msg == null) msg = "";
             if (obt == exp) { 
                 xpass(expression + ' == ' + exp + ' ' + msg);
@@ -108,7 +101,7 @@
             }
         }
     
-        public function check(a, msg) {
+        public static function check(a, msg) {
             if (a) {
                 pass(msg != undefined ? msg : a);
             }
@@ -117,7 +110,7 @@
             }
         }
     
-        public function xcheck(a, msg) {
+        public static function xcheck(a, msg) {
             if (a) { 
                 xpass(msg != undefined ? msg : a);
             }
@@ -126,31 +119,31 @@
             }
         }
     
-        public function note(msg) {
+        public static function note(msg) {
             xtrace(msg);
         }
     
-        public function untested(msg) {
+        public static function untested(msg) {
             trace("UNTESTED: "+msg);
         }
     
-        public function unresolved(msg) {
+        public static function unresolved(msg) {
             trace("UNRESOLVED: "+msg);
         }
     
         /// Private functions.
 
-        private function xtrace(msg) {
-            tf.text += msg + "\n";
+        private static function xtrace(msg) {
+            //tf.text += msg + "\n";
             trace(msg);
         }
 
-        private function done() {
+        private static function done() {
             printtotals();
             trace("__END_OF_TEST__");
         }
         
-        private function testcount() {
+        private static function testcount() {
             var c = 0;
             if ( passed ) c += passed;
             if ( failed ) c += failed;
@@ -159,7 +152,7 @@
             return c;
         }
     
-        private function printtotals() {
+        private static function printtotals() {
             xtrace('#passed: '+ passed);
             xtrace('#failed: '+ failed);
             if ( xpassed ) {


reply via email to

[Prev in Thread] Current Thread [Next in Thread]