Debian Codegraph @

rhino/testsrc/tests/lc3/JSNull/ToNumber-001-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 = 'ToNumber-001-n.js';
7
8 /* -*- Mode: java; tab-width: 8 -*-
9 * Copyright (C) 1997, 1998 Netscape Communications Corporation,
10 * All Rights Reserved.
11 */
12 /**
13 * JavaScript to Java type conversion.
14 *
15 * This test passes JavaScript number values to several Java methods
16 * that expect arguments of various types, and verifies that the value is
17 * converted to the correct value and type.
18 *
19 * This tests instance methods, and not static methods.
20 *
21 * Running these tests successfully requires you to have
22 * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath.
23 *
24 * Specification: Method Overloading Proposal for Liveconnect 3.0
25 *
26 * @author: [email protected]
27 *
28 */
29 var SECTION = "null";
30 var VERSION = "1_4";
31 var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " +
32 SECTION;
33 startTest();
34
35 var dt = new DT();
36
37 var a = new Array();
38 var i = 0;
39
40 // passing a JavaScript null to a method that expect a class or interface
41 // converts null to a java null. passing null to methods that expect
42 // number types convert null to 0. passing null to methods that expect
43 // a boolean convert null to false.
44
45 DESCRIPTION = "dt.setDouble( null )";
46 EXPECTED = "error";
47
48 a[i++] = new TestObject(
49 "dt.setDouble( null )",
50 "dt.PUB_DOUBLE",
51 "dt.getDouble()",
52 "typeof dt.getDouble()",
53 "error",
54 "error" );
55 /*
56 a[i++] = new TestObject(
57 "dt.setFloat( null )",
58 "dt.PUB_FLOAT",
59 "dt.getFloat()",
60 "typeof dt.getFloat()",
61 0,
62 "number" );
63
64 a[i++] = new TestObject(
65 "dt.setLong( null )",
66 "dt.PUB_LONG",
67 "dt.getLong()",
68 "typeof dt.getLong()",
69 0,
70 "number" );
71
72 a[i++] = new TestObject(
73 "dt.setInteger( null )",
74 "dt.PUB_INT",
75 "dt.getInteger()",
76 "typeof dt.getInteger()",
77 0,
78 "number" );
79
80 a[i++] = new TestObject(
81 "dt.setShort( null )",
82 "dt.PUB_SHORT",
83 "dt.getShort()",
84 "typeof dt.getShort()",
85 0,
86 "number" );
87
88 a[i++] = new TestObject(
89 "dt.setByte( null )",
90 "dt.PUB_BYTE",
91 "dt.getByte()",
92 "typeof dt.getByte()",
93 0,
94 "number" );
95
96 a[i++] = new TestObject(
97 "dt.setChar( null )",
98 "dt.PUB_CHAR",
99 "dt.getChar()",
100 "typeof dt.getChar()",
101 0,
102 "number" );
103 */
104
105 for ( i = 0; i < a.length; i++ ) {
106 new TestCase(
107 a[i].description +"; "+ a[i].javaFieldName,
108 a[i].jsValue,
109 a[i].javaFieldValue );
110
111 new TestCase(
112 a[i].description +"; " + a[i].javaMethodName,
113 a[i].jsValue,
114 a[i].javaMethodValue );
115
116 new TestCase(
117 a[i].javaTypeName,
118 a[i].jsType,
119 a[i].javaTypeValue );
120 }
121
122 test();
123
124 function TestObject( description, javaField, javaMethod, javaType,
125 jsValue, jsType )
126 {
127 eval (description );
128
129 this.description = description;
130 this.javaFieldName = javaField;
131 this.javaFieldValue = eval( javaField );
132 this.javaMethodName = javaMethod;
133 this.javaMethodValue = eval( javaMethod );
134 this.javaTypeName = javaType,
135 this.javaTypeValue = eval( javaType );
136
137 this.jsValue = jsValue;
138 this.jsType = jsType;
139 }