| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
var gTestfile = 'catchguard-001.js'; |
| 8 |
|
| 9 |
test(); |
| 10 |
|
| 11 |
function test() |
| 12 |
{ |
| 13 |
enterFunc ("test"); |
| 14 |
|
| 15 |
var EXCEPTION_DATA = "String exception"; |
| 16 |
var e = "foo"; |
| 17 |
var caught = false; |
| 18 |
|
| 19 |
printStatus ("Basic catchguard test."); |
| 20 |
|
| 21 |
try |
| 22 |
{ |
| 23 |
throw EXCEPTION_DATA; |
| 24 |
} |
| 25 |
catch (e if true) |
| 26 |
{ |
| 27 |
caught = true; |
| 28 |
e = "this change should not propagate outside of this scope"; |
| 29 |
} |
| 30 |
catch (e if false) |
| 31 |
{ |
| 32 |
reportCompare('PASS', 'FAIL', "Catch block (e if false) should not have executed."); |
| 33 |
} |
| 34 |
catch (e) |
| 35 |
{ |
| 36 |
reportCompare('PASS', 'FAIL', "Catch block (e) should not have executed."); |
| 37 |
} |
| 38 |
|
| 39 |
if (!caught) |
| 40 |
reportCompare('PASS', 'FAIL', "Exception was never caught."); |
| 41 |
|
| 42 |
if (e != "foo") |
| 43 |
reportCompare('PASS', 'FAIL', "Exception data modified inside catch() scope should " + |
| 44 |
"not be visible in the function scope (e = '" + |
| 45 |
e + "'.)"); |
| 46 |
|
| 47 |
reportCompare('PASS', 'PASS', ''); |
| 48 |
exitFunc ("test"); |
| 49 |
} |