changeset 148:7f86f1a807f8 core-javascript

Get testtools.js running on JSDB (and some minor changes).
author jf3243
date Mon, 31 Oct 2011 15:50:46 +0000
parents b04f509bee83
children b5028c976e41
files core-javascript/core-javascript-work/testtools.js core-javascript/index.rst core-javascript/testtools.rst
diffstat 3 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/core-javascript/core-javascript-work/testtools.js	Mon Oct 31 15:23:17 2011 +0000
+++ b/core-javascript/core-javascript-work/testtools.js	Mon Oct 31 15:50:46 2011 +0000
@@ -3,7 +3,7 @@
 
 // Define a global function 'log'.
 var log;
-if (this.hasOwnProperty('jsArguments')){
+if (this.writeln){             // True if JSDB.
     
     log = function(s){
         print(s + '\n');
@@ -12,7 +12,7 @@
     log = print;    
 }
 
-// 
+// Log name of test and run the code.
 var TEST = function(title, code){
 
     log( 'Testing: ' + title );
@@ -20,6 +20,7 @@
     code();
 };
 
+// Increment assertion code and report failure.
 var assert = function(arg){
     _assertion_count += 1;
     if (!arg){
--- a/core-javascript/index.rst	Mon Oct 31 15:23:17 2011 +0000
+++ b/core-javascript/index.rst	Mon Oct 31 15:50:46 2011 +0000
@@ -11,8 +11,8 @@
    :maxdepth: 2
 
    getting-started
+   testtools
    counters-example
-   testtools
 
 
 Objects
@@ -21,7 +21,6 @@
 .. toctree::
    :maxdepth: 2
 
-
    immutables
    equality
    objects
--- a/core-javascript/testtools.rst	Mon Oct 31 15:23:17 2011 +0000
+++ b/core-javascript/testtools.rst	Mon Oct 31 15:50:46 2011 +0000
@@ -53,15 +53,17 @@
 .. code-block:: sh
 
    C:core-javascript-work> jsdb -load testtools.js -load demo_testtools.js
+   Testing: 2-4-fail
    Testing: all-pass
    Testing: 2-4-fail
    ! assert 2 has failed
    ! assert 4 has failed
-   js>load('demo_testtools.js')  // You type this.
+   js>run('demo_testtools.js')  // You type this.
    Testing: all-pass
    Testing: 2-4-fail
    ! assert 2 has failed
    ! assert 4 has failed
+   true
    js>