Mercurial > js4py
view core-javascript/javascript-exercises/lib/testtools.js @ 193:4a2f30b0a9d5 javascript-exercises
Minor changes after testing in Windows.
| author | jf3243 |
|---|---|
| date | Mon, 21 Nov 2011 17:26:36 +0000 |
| parents | a89af6d539ee |
| children |
line wrap: on
line source
var telltail = 'global'; var _assertion_count = 0; // Define a global function 'log'. var log; if (this.writeln){ log = writeln; } else { log = function(s){ print(s + '\n'); }; } // var TEST = function(title, code){ var x; log( 'Testing: ' + title ); _assertion_count = 0; try { code(); } catch (x) { log(' ! Exception at ' + x.fileName +':' + x.lineNumber); log(' ! [' + x.name + '] ' + x.message ); } log(''); // Blank line at end of each test. }; var assert = function(arg){ _assertion_count += 1; if (!arg){ var msg = ' ! assert ' + _assertion_count + ' has failed'; log(msg); } }; var submit = function(name){ var filename = name + '-exercises.js'; var status = run(filename); if (!status){ writeln("Could not find file '" + filename + "'"); } };
