js/src/tests/ecma_2/Statements/try-010.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:c2fba34a1295
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
7 /**
8 * File Name: try-010.js
9 * ECMA Section:
10 * Description: The try statement
11 *
12 * This has a try block nested in the try block. Verify that the
13 * exception is caught by the right try block, and all finally blocks
14 * are executed.
15 *
16 * Author: christine@netscape.com
17 * Date: 11 August 1998
18 */
19 var SECTION = "try-010";
20 var VERSION = "ECMA_2";
21 var TITLE = "The try statement: try in a tryblock";
22
23 startTest();
24 writeHeaderToLog( SECTION + " "+ TITLE);
25
26 var EXCEPTION_STRING = "Exception thrown: ";
27 var NO_EXCEPTION_STRING = "No exception thrown: ";
28
29
30 NestedTry( new TryObject( "No Exceptions Thrown", NoException, NoException, 43 ) );
31 NestedTry( new TryObject( "Throw Exception in Outer Try", ThrowException, NoException, 48 ));
32 NestedTry( new TryObject( "Throw Exception in Inner Try", NoException, ThrowException, 45 ));
33 NestedTry( new TryObject( "Throw Exception in Both Trys", ThrowException, ThrowException, 48 ));
34
35 test();
36
37 function TryObject( description, tryOne, tryTwo, result ) {
38 this.description = description;
39 this.tryOne = tryOne;
40 this.tryTwo = tryTwo;
41 this.result = result;
42 }
43 function ThrowException() {
44 throw EXCEPTION_STRING + this.value;
45 }
46 function NoException() {
47 return NO_EXCEPTION_STRING + this.value;
48 }
49 function NestedTry( object ) {
50 result = 0;
51 try {
52 object.tryOne();
53 result += 1;
54 try {
55 object.tryTwo();
56 result += 2;
57 } catch ( e ) {
58 result +=4;
59 } finally {
60 result += 8;
61 }
62 } catch ( e ) {
63 result += 16;
64 } finally {
65 result += 32;
66 }
67
68 new TestCase(
69 SECTION,
70 object.description,
71 object.result,
72 result );
73 }

mercurial