Mercurial > js4py-pl
comparison core-javascript/core-javascript-work/testtools.js @ 152:82f672a37506 core-javascript.closure-exercises
In testtools.js catch and report exceptions.
| author | jf3243 |
|---|---|
| date | Wed, 02 Nov 2011 14:03:25 +0000 |
| parents | 20d76c716c9d |
| children | b774913eb242 |
comparison
equal
deleted
inserted
replaced
| 151:9cdf095a283e | 152:82f672a37506 |
|---|---|
| 13 } | 13 } |
| 14 | 14 |
| 15 // | 15 // |
| 16 var TEST = function(title, code){ | 16 var TEST = function(title, code){ |
| 17 | 17 |
| 18 var x; | |
| 19 | |
| 18 log( 'Testing: ' + title ); | 20 log( 'Testing: ' + title ); |
| 19 _assertion_count = 0; | 21 _assertion_count = 0; |
| 20 code(); | 22 |
| 23 try { | |
| 24 code(); | |
| 25 } catch (x) { | |
| 26 log('! Exception at ' + x.fileName +':' + x.lineNumber); | |
| 27 log('! [' + x.name + '] ' + x.message ); | |
| 28 } | |
| 29 | |
| 21 }; | 30 }; |
| 22 | 31 |
| 23 var assert = function(arg){ | 32 var assert = function(arg){ |
| 24 _assertion_count += 1; | 33 _assertion_count += 1; |
| 25 if (!arg){ | 34 if (!arg){ |
