Debian Codegraph @

rhino/testsrc/tests/ecma_2/Statements/try-010.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-010.js';
7
8 /**
9 * File Name: try-010.js
10 * ECMA Section:
11 * Description: The try statement
12 *
13 * This has a try block nested in the try block. Verify that the
14 * exception is caught by the right try block, and all finally blocks
15 * are executed.
16 *
17 * Author: [email protected]
18 * Date: 11 August 1998
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 }