Debian Codegraph @

rhino/testsrc/tests/ecma_2/Statements/try-003.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = 'try-003.js';
7
8 /**
9 * File Name: try-003.js
10 * ECMA Section:
11 * Description: The try statement
12 *
13 * This test has a try with no catch, and a finally.
14 *
15 * Author: [email protected]
16 * Date: 11 August 1998
17 */
18 var SECTION = "try-003";
19 var VERSION = "ECMA_2";
20 var TITLE = "The try statement";
21 var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=313585";
22
23 startTest();
24 writeHeaderToLog( SECTION + " "+ TITLE);
25
26 // Tests start here.
27
28 TrySomething( "x = \"hi\"", false );
29 TrySomething( "throw \"boo\"", true );
30 TrySomething( "throw 3", true );
31
32 test();
33
34 /**
35 * This function contains a try block with no catch block,
36 * but it does have a finally block. Try to evaluate expressions
37 * that do and do not throw exceptions.
38 */
39
40 function TrySomething( expression, throwing ) {
41 innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK";
42 if (throwing) {
43 outerCatch = "FAILED: NO EXCEPTION CAUGHT";
44 } else {
45 outerCatch = "PASS";
46 }
47 outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK";
48
49 try {
50 try {
51 eval( expression );
52 } finally {
53 innerFinally = "PASS";
54 }
55 } catch ( e ) {
56 if (throwing) {
57 outerCatch = "PASS";
58 } else {
59 outerCatch = "FAIL: HIT OUTER CATCH BLOCK";
60 }
61 } finally {
62 outerFinally = "PASS";
63 }
64
65
66 new TestCase(
67 SECTION,
68 "eval( " + expression +" )",
69 "PASS",
70 innerFinally );
71 new TestCase(
72 SECTION,
73 "eval( " + expression +" )",
74 "PASS",
75 outerCatch );
76 new TestCase(
77 SECTION,
78 "eval( " + expression +" )",
79 "PASS",
80 outerFinally );
81
82
83 }