]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_2/Statements/try-012.js
2 * File Name: try-012.js
4 * Description: The try statement
6 * This test has a try with no catch, and a finally. This is like try-003,
7 * but throws from a finally block, not the try block.
9 * Author: christine@netscape.com
10 * Date: 11 August 1998
12 var SECTION
= "try-012";
13 var VERSION
= "ECMA_2";
14 var TITLE
= "The try statement";
15 var BUGNUMBER
="336872";
18 writeHeaderToLog( SECTION
+ " "+ TITLE
);
21 var testcases
= new Array();
25 TrySomething( "x = \"hi\"", true );
26 TrySomething( "throw \"boo\"", true );
27 TrySomething( "throw 3", true );
32 * This function contains a try block with no catch block,
33 * but it does have a finally block. Try to evaluate expressions
34 * that do and do not throw exceptions.
36 * The productioni TryStatement Block Finally is evaluated as follows:
39 * 3. If Result(2).type is normal return result 1 (in the test case, result 1 has
40 * the completion type throw)
41 * 4. return result 2 (does not get hit in this case)
45 function TrySomething( expression
, throwing
) {
46 innerFinally
= "FAIL: DID NOT HIT INNER FINALLY BLOCK";
48 outerCatch
= "FAILED: NO EXCEPTION CAUGHT";
52 outerFinally
= "FAIL: DID NOT HIT OUTER FINALLY BLOCK";
55 // If the inner finally does not throw an exception, the result
56 // of the try block should be returned. (Type of inner return
57 // value should be throw if finally executes correctly
63 innerFinally
= "PASS";
70 outerCatch
= "FAIL: HIT OUTER CATCH BLOCK";
73 outerFinally
= "PASS";
77 testcases
[tc
++] = new TestCase(
79 "eval( " + expression
+" ): evaluated inner finally block",
82 testcases
[tc
++] = new TestCase(
84 "eval( " + expression
+" ): evaluated outer catch block ",
87 testcases
[tc
++] = new TestCase(
89 "eval( " + expression
+" ): evaluated outer finally block",