]>
Commit | Line | Data |
---|---|---|
b37bf2e1 A |
1 | /** |
2 | * File Name: try-003.js | |
3 | * ECMA Section: | |
4 | * Description: The try statement | |
5 | * | |
6 | * This test has a try with no catch, and a finally. | |
7 | * | |
8 | * Author: christine@netscape.com | |
9 | * Date: 11 August 1998 | |
10 | */ | |
11 | var SECTION = "try-003"; | |
12 | var VERSION = "ECMA_2"; | |
13 | var TITLE = "The try statement"; | |
14 | var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=313585"; | |
15 | ||
16 | startTest(); | |
17 | writeHeaderToLog( SECTION + " "+ TITLE); | |
18 | ||
19 | var tc = 0; | |
20 | var testcases = new Array(); | |
21 | ||
22 | // Tests start here. | |
23 | ||
24 | TrySomething( "x = \"hi\"", false ); | |
25 | TrySomething( "throw \"boo\"", true ); | |
26 | TrySomething( "throw 3", true ); | |
27 | ||
28 | test(); | |
29 | ||
30 | /** | |
31 | * This function contains a try block with no catch block, | |
32 | * but it does have a finally block. Try to evaluate expressions | |
33 | * that do and do not throw exceptions. | |
34 | */ | |
35 | ||
36 | function TrySomething( expression, throwing ) { | |
37 | innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; | |
38 | if (throwing) { | |
39 | outerCatch = "FAILED: NO EXCEPTION CAUGHT"; | |
40 | } else { | |
41 | outerCatch = "PASS"; | |
42 | } | |
43 | outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; | |
44 | ||
45 | try { | |
46 | try { | |
47 | eval( expression ); | |
48 | } finally { | |
49 | innerFinally = "PASS"; | |
50 | } | |
51 | } catch ( e ) { | |
52 | if (throwing) { | |
53 | outerCatch = "PASS"; | |
54 | } else { | |
55 | outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; | |
56 | } | |
57 | } finally { | |
58 | outerFinally = "PASS"; | |
59 | } | |
60 | ||
61 | ||
62 | testcases[tc++] = new TestCase( | |
63 | SECTION, | |
64 | "eval( " + expression +" )", | |
65 | "PASS", | |
66 | innerFinally ); | |
67 | testcases[tc++] = new TestCase( | |
68 | SECTION, | |
69 | "eval( " + expression +" )", | |
70 | "PASS", | |
71 | outerCatch ); | |
72 | testcases[tc++] = new TestCase( | |
73 | SECTION, | |
74 | "eval( " + expression +" )", | |
75 | "PASS", | |
76 | outerFinally ); | |
77 | ||
78 | ||
79 | } |