Debian Codegraph @

rhino/testsrc/tests/ecma_2/Statements/try-004.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-004.js';
7
8 /**
9 * File Name: try-004.js
10 * ECMA Section:
11 * Description: The try statement
12 *
13 * This test has a try with one catch block but no finally.
14 *
15 * Author: [email protected]
16 * Date: 11 August 1998
17 */
18 var SECTION = "try-004";
19 var VERSION = "ECMA_2";
20 var TITLE = "The try statement";
21
22 startTest();
23 writeHeaderToLog( SECTION + " "+ TITLE);
24
25 TryToCatch( "Math.PI", Math.PI );
26 TryToCatch( "Thrower(5)", "Caught 5" );
27 TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" );
28
29 test();
30
31 function Thrower( v ) {
32 throw "Caught " + v;
33 }
34
35 /**
36 * Evaluate a string. Catch any exceptions thrown. If no exception is
37 * expected, verify the result of the evaluation. If an exception is
38 * expected, verify that we got the right exception.
39 */
40
41 function TryToCatch( value, expect ) {
42 try {
43 result = eval( value );
44 } catch ( e ) {
45 result = e;
46 }
47
48 new TestCase(
49 SECTION,
50 "eval( " + value +" )",
51 expect,
52 result );
53 }
54
55