Mercurial > js4py
view core-javascript/javascript-exercises/lib/testtools.js @ 182:a89af6d539ee javascript-exercises
$ hg mv javascript-exercises/testtools.js javascript-exercises/lib/
| author | jf3243 |
|---|---|
| date | Thu, 17 Nov 2011 15:46:42 +0000 |
| parents | core-javascript/javascript-exercises/testtools.js@19e88fb18c4e |
| children | 4a2f30b0a9d5 |
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 ); } }; 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 + "'"); } };
