Debian Codegraph @

rhino/testsrc/tests/ecma_2/Statements/try-008.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-008.js';
7
8 /**
9 * File Name: try-008.js
10 * ECMA Section:
11 * Description: The try statement
12 *
13 * This test has a try block in a constructor.
14 *
15 *
16 * Author: [email protected]
17 * Date: 11 August 1998
18 */
19 var SECTION = "try-008";
20 var VERSION = "ECMA_2";
21 var TITLE = "The try statement: try in a constructor";
22
23 startTest();
24 writeHeaderToLog( SECTION + " "+ TITLE);
25
26 function Integer( value, exception ) {
27 try {
28 this.value = checkValue( value );
29 } catch ( e ) {
30 this.value = e.toString();
31 }
32
33 new TestCase(
34 SECTION,
35 "Integer( " + value +" )",
36 (exception ? INVALID_INTEGER_VALUE +": " + value : this.value),
37 this.value );
38 }
39
40 var INVALID_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor";
41
42 function checkValue( value ) {
43 if ( Math.floor(value) != value || isNaN(value) ) {
44 throw ( INVALID_INTEGER_VALUE +": " + value );
45 } else {
46 return value;
47 }
48 }
49
50 // add test cases
51
52 new Integer( 3, false );
53 new Integer( NaN, true );
54 new Integer( 0, false );
55 new Integer( Infinity, false );
56 new Integer( -2.12, true );
57 new Integer( Math.LN2, true );
58
59
60 test();