Debian Codegraph @

rhino/testsrc/tests/lc3/JSNumber/ToChar-005-n.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 = 'ToChar-005-n.js';
7
8 /* -*- Mode: java; tab-width: 8 -*-
9 * Copyright (C) 1997, 1998 Netscape Communications Corporation,
10 * All Rights Reserved.
11 */
12
13 /**
14 * JavaScript to Java type conversion.
15 *
16 * This test passes JavaScript number values to several Java methods
17 * that expect arguments of various types, and verifies that the value is
18 * converted to the correct value and type.
19 *
20 * This tests instance methods, and not static methods.
21 *
22 * Running these tests successfully requires you to have
23 * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath.
24 *
25 * Specification: Method Overloading Proposal for Liveconnect 3.0
26 *
27 * @author: [email protected]
28 *
29 */
30 var SECTION = "number conversion to char";
31 var VERSION = "1_4";
32 var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " +
33 SECTION;
34 startTest();
35
36 var dt = new DT();
37
38 var a = new Array();
39 var i = 0;
40
41 // passing a JS number to a method that expects a char:
42 // round JS number to integral value using round-to-negative-infinity mode
43 // numbers with a magnitude too large to be represented in the target integral
44 // type result in a runtime error.
45 // Nan converts to 0.
46
47 // Special cases: 0, -0, Infinity, -Infinity, and NaN
48
49 DESCRIPTION = "dt.setChar( NaN )";
50 EXPECTED = "error";
51
52 a[i++] = new TestObject(
53 "dt.setChar( NaN )",
54 "dt.PUB_CHAR",
55 "dt.getChar()",
56 "typeof dt.getChar()",
57 "error",
58 "error" );
59
60 for ( i = 0; i < a.length; i++ ) {
61 new TestCase(
62 a[i].description +"; "+ a[i].javaFieldName,
63 a[i].jsValue,
64 a[i].javaFieldValue );
65
66 new TestCase(
67 a[i].description +"; " + a[i].javaMethodName,
68 a[i].jsValue,
69 a[i].javaMethodValue );
70
71 new TestCase(
72 a[i].javaTypeName,
73 a[i].jsType,
74 a[i].javaTypeValue );
75 }
76
77 test();
78
79 function TestObject( description, javaField, javaMethod, javaType,
80 jsValue, jsType )
81 {
82 eval (description );
83
84 this.description = description;
85 this.javaFieldName = javaField;
86 this.javaFieldValue = eval( javaField );
87 this.javaMethodName = javaMethod;
88 this.javaMethodValue = eval( javaMethod );
89 this.javaTypeName = javaType,
90 this.javaTypeValue = eval( javaType );
91
92 this.jsValue = jsValue;
93 this.jsType = jsType;
94 }