| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
var gTestfile = 'catchguard-002.js'; |
| 8 |
|
| 9 |
test(); |
| 10 |
|
| 11 |
function test() |
| 12 |
{ |
| 13 |
enterFunc ("test"); |
| 14 |
|
| 15 |
var EXCEPTION_DATA = "String exception"; |
| 16 |
var e; |
| 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 |
} |
| 29 |
catch (e if true) |
| 30 |
{ |
| 31 |
reportCompare('PASS', 'FAIL', |
| 32 |
"Second (e if true) catch block 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 |
reportCompare('PASS', 'PASS', 'Basic catchguard test'); |
| 43 |
|
| 44 |
exitFunc ("test"); |
| 45 |
} |