Debian Codegraph @

rhino/testsrc/tests/lc3/JSNull/ToFloat-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 = 'ToFloat-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.setFloat( null )";
46 EXPECTED = "error";
47
48 a[i++] = new TestObject(
49 "dt.setFloat( null )",
50 "dt.PUB_FLOAT",
51 "dt.getFloat()",
52 "typeof dt.getFloat()",
53 "error",
54 "error" );
55 /*
56 a[i++] = new TestObject(
57 "dt.setLong( null )",
58 "dt.PUB_LONG",
59 "dt.getLong()",
60 "typeof dt.getLong()",
61 0,
62 "number" );
63
64 a[i++] = new TestObject(
65 "dt.setInteger( null )",
66 "dt.PUB_INT",
67 "dt.getInteger()",
68 "typeof dt.getInteger()",
69 0,
70 "number" );
71
72 a[i++] = new TestObject(
73 "dt.setShort( null )",
74 "dt.PUB_SHORT",
75 "dt.getShort()",
76 "typeof dt.getShort()",
77 0,
78 "number" );
79
80 a[i++] = new TestObject(
81 "dt.setByte( null )",
82 "dt.PUB_BYTE",
83 "dt.getByte()",
84 "typeof dt.getByte()",
85 0,
86 "number" );
87
88 a[i++] = new TestObject(
89 "dt.setChar( null )",
90 "dt.PUB_CHAR",
91 "dt.getChar()",
92 "typeof dt.getChar()",
93 0,
94 "number" );
95 */
96
97 for ( i = 0; i < a.length; i++ ) {
98 new TestCase(
99 a[i].description +"; "+ a[i].javaFieldName,
100 a[i].jsValue,
101 a[i].javaFieldValue );
102
103 new TestCase(
104 a[i].description +"; " + a[i].javaMethodName,
105 a[i].jsValue,
106 a[i].javaMethodValue );
107
108 new TestCase(
109 a[i].javaTypeName,
110 a[i].jsType,
111 a[i].javaTypeValue );
112 }
113
114 test();
115
116 function TestObject( description, javaField, javaMethod, javaType,
117 jsValue, jsType )
118 {
119 eval (description );
120
121 this.description = description;
122 this.javaFieldName = javaField;
123 this.javaFieldValue = eval( javaField );
124 this.javaMethodName = javaMethod;
125 this.javaMethodValue = eval( javaMethod );
126 this.javaTypeName = javaType,
127 this.javaTypeValue = eval( javaType );
128
129 this.jsValue = jsValue;
130 this.jsType = jsType;
131 }