| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
var gTestfile = 'catchguard-003.js'; |
| 8 |
|
| 9 |
test(); |
| 10 |
|
| 11 |
function test() |
| 12 |
{ |
| 13 |
enterFunc ("test"); |
| 14 |
|
| 15 |
var EXCEPTION_DATA = "String exception"; |
| 16 |
var e = "foo", x = "foo"; |
| 17 |
var caught = false; |
| 18 |
|
| 19 |
printStatus ("Catchguard 'Common Scope' test."); |
| 20 |
|
| 21 |
try |
| 22 |
{ |
| 23 |
throw EXCEPTION_DATA; |
| 24 |
} |
| 25 |
catch (e if ((x = 1) && false)) |
| 26 |
{ |
| 27 |
reportCompare('PASS', 'FAIL', |
| 28 |
"Catch block (e if ((x = 1) && false) should not " + |
| 29 |
"have executed."); |
| 30 |
} |
| 31 |
catch (e if (x == 1)) |
| 32 |
{ |
| 33 |
caught = true; |
| 34 |
} |
| 35 |
catch (e) |
| 36 |
{ |
| 37 |
reportCompare('PASS', 'FAIL', |
| 38 |
"Same scope should be used across all catchguards."); |
| 39 |
} |
| 40 |
|
| 41 |
if (!caught) |
| 42 |
reportCompare('PASS', 'FAIL', |
| 43 |
"Exception was never caught."); |
| 44 |
|
| 45 |
if (e != "foo") |
| 46 |
reportCompare('PASS', 'FAIL', |
| 47 |
"Exception data modified inside catch() scope should " + |
| 48 |
"not be visible in the function scope (e ='" + |
| 49 |
e + "'.)"); |
| 50 |
|
| 51 |
if (x != 1) |
| 52 |
reportCompare('PASS', 'FAIL', |
| 53 |
"Data modified in 'catchguard expression' should " + |
| 54 |
"be visible in the function scope (x = '" + |
| 55 |
x + "'.)"); |
| 56 |
|
| 57 |
reportCompare('PASS', 'PASS', 'Catchguard Common Scope test'); |
| 58 |
|
| 59 |
exitFunc ("test"); |
| 60 |
} |