Revision: 1701
          http://svn.sourceforge.net/vexi/?rev=1701&view=rev
Author:   mkpg2
Date:     2007-02-27 10:26:25 -0800 (Tue, 27 Feb 2007)

Log Message:
-----------
Development. Concept of 'quick suite'. Moved vunit to vexi.test.

Modified Paths:
--------------
    vunit/trunk/org.vexi.vunit/src/org/vexi/vunit/viewer/util.t
    vunit/trunk/org.vexi.vunit/src/org/vexi/vunit/viewer/viewer.t
    vunit/trunk/org.vexi.vunit/src_dev/test_tests.t

Added Paths:
-----------
    vunit/trunk/org.vexi.vunit/src/vexi/
    vunit/trunk/org.vexi.vunit/src/vexi/test/
    vunit/trunk/org.vexi.vunit/src/vexi/test/vunit.t
    vunit/trunk/org.vexi.vunit/src_dev/

Removed Paths:
-------------
    vunit/trunk/org.vexi.vunit/src/org/vexi/vunit/vunit.t
    vunit/trunk/org.vexi.vunit/src_vunit/

Modified: vunit/trunk/org.vexi.vunit/src/org/vexi/vunit/viewer/util.t
===================================================================
--- vunit/trunk/org.vexi.vunit/src/org/vexi/vunit/viewer/util.t 2007-02-27 
05:25:08 UTC (rev 1700)
+++ vunit/trunk/org.vexi.vunit/src/org/vexi/vunit/viewer/util.t 2007-02-27 
18:26:25 UTC (rev 1701)
@@ -18,7 +18,7 @@
   
   static.switchcolors = function(widget){
     var inverted = widget._inverted_!=null;
-    vexi.log.info("switchcolors " + inverted);
+    //vexi.log.info("switchcolors " + inverted);
        
     
     if(inverted){

Modified: vunit/trunk/org.vexi.vunit/src/org/vexi/vunit/viewer/viewer.t
===================================================================
--- vunit/trunk/org.vexi.vunit/src/org/vexi/vunit/viewer/viewer.t       
2007-02-27 05:25:08 UTC (rev 1700)
+++ vunit/trunk/org.vexi.vunit/src/org/vexi/vunit/viewer/viewer.t       
2007-02-27 18:26:25 UTC (rev 1701)
@@ -27,7 +27,7 @@
   var currentNode = null;
   static.listener = {
     startTest: function(test){
-      print("+" + test.name);
+      //print("+" + test.name);
       var node;
       if(test.nbtests!=null){
         //Suite
@@ -66,12 +66,12 @@
     failTest: function(e, depth){
       currentNode.fail(e, depth);
       currentNode = currentNode.parent;
-      print(e.message + " at :" );
+      //print(e.message + " at :" );
       //
       var stackDepth = static.initialStackDepth + 
static.listener.hierarchyDepth;
-      for(var i=0; e.stackTrace.length-stackDepth>i; i++){
-        print(e.stackTrace[i]);
-      }
+      //for(var i=0; e.stackTrace.length-stackDepth>i; i++){
+        //print(e.stackTrace[i]);
+      //}
       displayDepth--;
     }
   };

Deleted: vunit/trunk/org.vexi.vunit/src/org/vexi/vunit/vunit.t
===================================================================
--- vunit/trunk/org.vexi.vunit/src/org/vexi/vunit/vunit.t       2007-02-27 
05:25:08 UTC (rev 1700)
+++ vunit/trunk/org.vexi.vunit/src/org/vexi/vunit/vunit.t       2007-02-27 
18:26:25 UTC (rev 1701)
@@ -1,148 +0,0 @@
-<!-- Copyleft 2004 - see COPYING for details [LGPL] -->
-<vexi xmlns:meta="vexi://meta" xmlns:ui="vexi://ui"  
xmlns:vunit="org.vexi.vunit" >
-   <meta:doc>
-      Author: Mike
-   </meta:doc>
-
-       //////
-       // TEST SUITE
-       ///
-       static.newTestSuite = function(suitename){
-         var r = {name: suitename, _tests:[]};
-         r.addTest = function(test){
-           if(test==null){
-               throw "adding null test";
-           };
-           r._tests[r._tests.length] = test;
-         };
-         r.addTests = function(/*varargs*/){
-           for(var i=0; arguments.length>i; i++){
-                   r.addTest(arguments[i]);
-               }
-         };
-         r.getTest = function(i){
-           return r._tests[i];
-         };
-         r.nbtests ++= function(){
-               return r._tests.length;
-         };
-         return r;
-       };
-       
-       
-       ///////////
-       // IMPLEMENTATION
-       /////
-       var initialStackDepth;
-       var depth=-1;
-       var rootTest = newTestSuite("All Tests");
-       
-       // FEATURE - don't resolve unless used somehow (stop us building the 
template unnecessarily
-       var testListener = vexi..org.vexi.vunit.listeners..graphical;
-       
-       var executeTest = function(test){
-               // Yield to make sure viewer can execute
-               vexi.thread.yield();
-       
-       
-               // START TEST
-               testListener.startTest(test);
-               depth++;
-               if(test.nbtests!=null){
-                       // Test Suite
-                       for(var i=0; test.nbtests>i; i++){
-                               executeTest(test.getTest(i));           
-                       }
-               }else{
-                       // Test Case
-                       try{
-                               test.run();
-                       }catch(e){
-                               // FAILED
-                               
testListener.failTest(e,depth+initialStackDepth);
-                               depth--;
-                               return;
-                       }
-               }
-               // END TEST
-               testListener.endTest();
-               depth--;
-       };
-       
-       
-       
-       //////////
-       // Public interface
-       ///////
-       static.getRootTest = function(){
-               return rootTest;
-       };
-       
-       static.setTestListener = function(aTestListener){
-               testListener = aTestListener;
-       };
-       
-       //  executeTest corresponds to junit.framework.Test.run
-       static.runTest = function(test){
-               // Calculate size of stack trace at this point
-               // so we know not to display it later ...
-               var depth;
-               try{
-                       throw "";
-               }catch(e){
-                       initialStackDepth = e.stackTrace.length;
-               }
-               
-               executeTest(test);
-       };
-       
-       // Optionally can name the rootTest (for display in the test runner 
later)
-       static.setRootTestName = function(name){
-               rootTest.name = name;
-       };
-       
-       static.runTests = function(){
-               static.runTest(rootTest);
-       };
-       
-       //  countTestCases corresponds to junit.framework.Test.countTestCases
-       static.countTestCases = function(test){
-               if(test.nbtests!=null){
-                       // Test Suite
-                       var count = 0;
-                       if(test.nbtests==0)
-                               vexi.log.warn("[Warning] Empty test suite : " + 
test.name);
-                       for(var i=0; test.nbtests>i; i++){
-                               count+= static.countTestCases(test.getTest(i)); 
        
-                       }
-                       return count;
-               }else{
-                       // Test Case
-                       return 1;
-               }
-       };
-       
-       
-       //////////
-       // Assertion stuff
-       ///////
-       static.assertEquals = function(expected,actual){
-               if(expected !=actual){
-                       throw "Expected: '" + expected + "'\n" +
-                             "Actual:   '"  + actual +"'";
-               }
-       }
-       
-    // For floats
-       static.assertApproxEquals = function(expected,actual){
-           var diff = (expected - actual);
-           if(diff*1000000>1){
-                       throw "Expected: '~" + expected + "'\n" +
-                             "Actual:   '"  + actual +"'";
-               }
-       }
-
-       
-  <ui:box/>
-
-</vexi>

Copied: vunit/trunk/org.vexi.vunit/src/vexi/test/vunit.t (from rev 1700, 
vunit/trunk/org.vexi.vunit/src/org/vexi/vunit/vunit.t)
===================================================================
--- vunit/trunk/org.vexi.vunit/src/vexi/test/vunit.t                            
(rev 0)
+++ vunit/trunk/org.vexi.vunit/src/vexi/test/vunit.t    2007-02-27 18:26:25 UTC 
(rev 1701)
@@ -0,0 +1,179 @@
+<!-- Copyleft 2004 - see COPYING for details [LGPL] -->
+<vexi xmlns:meta="vexi://meta" xmlns:ui="vexi://ui"  
xmlns:vunit="org.vexi.vunit" >
+   <meta:doc>
+      Author: Mike
+      <usage>
+       Add tests to the root test suite. Tests are either testcases
+       or test suites (building a tree of tests, with test cases as leaves).
+       
+       After root test suite is complete call runTests which will execute
+       all test cases (depth first traversal of all tests).
+      </usage>
+   </meta:doc>
+
+       //////
+       // TEST OBJECTS (suites,cases)
+       ///
+       static.newTestCase = function(name,f){
+               return {name:name, run:f};
+       };
+       
+       static.newTestSuite = function(suitename){
+         var r = {name: suitename, _tests:[]};
+         r.addTest = function(test){
+           if(test==null){
+               throw "adding null test";
+           };
+           r._tests[r._tests.length] = test;
+         };
+         r.addTests = function(/*varargs*/){
+           for(var i=0; arguments.length>i; i++){
+                   r.addTest(arguments[i]);
+               }
+         };
+         r.getTest = function(i){
+           return r._tests[i];
+         };
+         r.nbtests ++= function(){
+               return r._tests.length;
+         };
+         return r;
+       };
+       
+       
+       // Creates a testsuite + testcases from an object 
+       // with functions(tests) using the naming convention
+       // testxxx. Where xxx will be the name of the test.
+       static.newQuickSuite = function(suitename, obj){
+               var r = newTestSuite(suitename);
+               var v;
+               for(v in obj){
+                       if(v.length>4 and v.substr(0,4)=="test"){
+                               var name = v.substr(4,v.length-4);
+                               var tcase = newTestCase(name, obj[v]);
+                               vexi.log.info("adding: " + name);
+                               r.addTest(tcase);
+                       }
+               }
+               return r;
+       };
+       
+       ///////////
+       // IMPLEMENTATION
+       /////
+       var initialStackDepth;
+       var depth=-1;
+       var rootTest = newTestSuite("All Tests");
+       
+       // FEATURE - don't resolve unless used somehow (stop us building the 
template unnecessarily
+       var testListener = vexi..org.vexi.vunit.listeners..graphical;
+       
+       var executeTest = function(test){
+               // Yield to make sure viewer can execute
+               vexi.thread.yield();
+       
+       
+               // START TEST
+               testListener.startTest(test);
+               depth++;
+               if(test.nbtests!=null){
+                       // Test Suite
+                       for(var i=0; test.nbtests>i; i++){
+                               executeTest(test.getTest(i));           
+                       }
+               }else{
+                       // Test Case
+                       try{
+                               test.run();
+                       }catch(e){
+                               // FAILED
+                               
testListener.failTest(e,depth+initialStackDepth);
+                               depth--;
+                               return;
+                       }
+               }
+               // END TEST
+               testListener.endTest();
+               depth--;
+       };
+       
+       
+       
+       //////////
+       // Public interface
+       ///////
+       static.getRootTest = function(){
+               return rootTest;
+       };
+       
+       static.setTestListener = function(aTestListener){
+               testListener = aTestListener;
+       };
+       
+       //  executeTest corresponds to junit.framework.Test.run
+       static.runTest = function(test){
+               // Calculate size of stack trace at this point
+               // so we know not to display it later ...
+               var depth;
+               try{
+                       throw "";
+               }catch(e){
+                       initialStackDepth = e.stackTrace.length;
+               }
+               
+               executeTest(test);
+       };
+       
+       // Optionally can name the rootTest (for display in the test runner 
later)
+       static.setRootTestName = function(name){
+               rootTest.name = name;
+       };
+       
+       static.runTests = function(){
+               static.runTest(rootTest);
+       };
+       
+       //  countTestCases corresponds to junit.framework.Test.countTestCases
+       static.countTestCases = function(test){
+               if(test.nbtests!=null){
+                       // Test Suite
+                       var count = 0;
+                       if(test.nbtests==0)
+                               vexi.log.warn("[Warning] Empty test suite : " + 
test.name);
+                       for(var i=0; test.nbtests>i; i++){
+                               count+= static.countTestCases(test.getTest(i)); 
        
+                       }
+                       return count;
+               }else{
+                       // Test Case
+                       return 1;
+               }
+       };
+       
+       
+       //////////
+       // Assertion stuff
+       ///////
+       static.assertEquals = function(expected,actual){
+               if(expected !=actual){
+                       throw "Expected: '" + expected + "'\n" +
+                             "Actual:   '"  + actual +"'";
+               }
+       }
+       
+    // For floats
+       static.assertApproxEquals = function(expected,actual){
+           var diff = (expected - actual);
+           if(diff*1000000>1){
+                       throw "Expected: '~" + expected + "'\n" +
+                             "Actual:   '"  + actual +"'";
+               }
+       }
+
+       
+    <ui:box>
+       thisbox.assertEquals = static.assertEquals;
+       thisbox.assertApproxEquals = static.assertApproxEquals;
+    </ui:box>
+
+</vexi>

Copied: vunit/trunk/org.vexi.vunit/src_dev (from rev 1700, 
vunit/trunk/org.vexi.vunit/src_vunit)

Modified: vunit/trunk/org.vexi.vunit/src_dev/test_tests.t
===================================================================
--- vunit/trunk/org.vexi.vunit/src_vunit/test_tests.t   2007-02-27 05:25:08 UTC 
(rev 1700)
+++ vunit/trunk/org.vexi.vunit/src_dev/test_tests.t     2007-02-27 18:26:25 UTC 
(rev 1701)
@@ -6,7 +6,7 @@
     
     vexi.log.error("N_GENTESTS- "  + static.N_GENTESTS);
     
-    var vunit = vexi..org.vexi.vunit.vunit;
+    var vunit = vexi..vexi.test.vunit;
     var speed = 0;
        
        var pause = function(t){
@@ -65,9 +65,26 @@
        
 
        rootTest.addTest(genSuite);
-                                         
-       vexi.thread = function(){
-               vunit..runTests("test tests");                                  
-       };
-   <ui:box/>
+       
+       /// Quick Suite
+       var quickSuite = {};
+       quickSuite.testQ1 = function(){
+               pause(200);
+               assert(false);
+       };      
+       quickSuite.testQ2 = function(){
+               pause(200);
+               assert(true);
+       };      
+
+       rootTest.addTest(vunit..newQuickSuite("Quick Suite", quickSuite));
+                         
+   <ui:box>
+          var vunit = vexi..vexi.test.vunit;
+       vexi.thread = function(){
+                       vunit..runTests("test tests");                          
        
+               };
+   </ui:box>
+   
+   
 </vexi>
\ No newline at end of file


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to