| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
gTestfile = 'try-010.js'; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
var SECTION = "try-010"; |
| 21 |
var VERSION = "ECMA_2"; |
| 22 |
var TITLE = "The try statement: try in a tryblock"; |
| 23 |
|
| 24 |
startTest(); |
| 25 |
writeHeaderToLog( SECTION + " "+ TITLE); |
| 26 |
|
| 27 |
var EXCEPTION_STRING = "Exception thrown: "; |
| 28 |
var NO_EXCEPTION_STRING = "No exception thrown: "; |
| 29 |
|
| 30 |
|
| 31 |
NestedTry( new TryObject( "No Exceptions Thrown", NoException, NoException, 43 ) ); |
| 32 |
NestedTry( new TryObject( "Throw Exception in Outer Try", ThrowException, NoException, 48 )); |
| 33 |
NestedTry( new TryObject( "Throw Exception in Inner Try", NoException, ThrowException, 45 )); |
| 34 |
NestedTry( new TryObject( "Throw Exception in Both Trys", ThrowException, ThrowException, 48 )); |
| 35 |
|
| 36 |
test(); |
| 37 |
|
| 38 |
function TryObject( description, tryOne, tryTwo, result ) { |
| 39 |
this.description = description; |
| 40 |
this.tryOne = tryOne; |
| 41 |
this.tryTwo = tryTwo; |
| 42 |
this.result = result; |
| 43 |
} |
| 44 |
function ThrowException() { |
| 45 |
throw EXCEPTION_STRING + this.value; |
| 46 |
} |
| 47 |
function NoException() { |
| 48 |
return NO_EXCEPTION_STRING + this.value; |
| 49 |
} |
| 50 |
function NestedTry( object ) { |
| 51 |
result = 0; |
| 52 |
try { |
| 53 |
object.tryOne(); |
| 54 |
result += 1; |
| 55 |
try { |
| 56 |
object.tryTwo(); |
| 57 |
result += 2; |
| 58 |
} catch ( e ) { |
| 59 |
result +=4; |
| 60 |
} finally { |
| 61 |
result += 8; |
| 62 |
} |
| 63 |
} catch ( e ) { |
| 64 |
result += 16; |
| 65 |
} finally { |
| 66 |
result += 32; |
| 67 |
} |
| 68 |
|
| 69 |
new TestCase( |
| 70 |
SECTION, |
| 71 |
object.description, |
| 72 |
object.result, |
| 73 |
result ); |
| 74 |
} |