Mercurial > js4py
comparison core-javascript/core-javascript-work/testtools.js @ 150:5118d0e38ba4 core-javascript-latex
$ hg merge core-javascript # into core-javascript-latex
| author | jf3243 |
|---|---|
| date | Tue, 01 Nov 2011 08:58:38 +0000 |
| parents | 20d76c716c9d |
| children | 82f672a37506 |
comparison
equal
deleted
inserted
replaced
| 136:5666f217df39 | 150:5118d0e38ba4 |
|---|---|
| 1 var telltail = 'global'; | |
| 2 var _assertion_count = 0; | |
| 3 | |
| 4 // Define a global function 'log'. | |
| 5 var log; | |
| 6 if (this.hasOwnProperty('jsArguments')){ | |
| 7 | |
| 8 log = function(s){ | |
| 9 print(s + '\n'); | |
| 10 }; | |
| 11 } else { | |
| 12 log = print; | |
| 13 } | |
| 14 | |
| 15 // | |
| 16 var TEST = function(title, code){ | |
| 17 | |
| 18 log( 'Testing: ' + title ); | |
| 19 _assertion_count = 0; | |
| 20 code(); | |
| 21 }; | |
| 22 | |
| 23 var assert = function(arg){ | |
| 24 _assertion_count += 1; | |
| 25 if (!arg){ | |
| 26 var msg = '! assert ' + _assertion_count + ' has failed'; | |
| 27 log(msg); | |
| 28 } | |
| 29 }; | |
| 30 |
