Debian Codegraph @

rhino/testsrc/tests/lc3/JavaArray/ToBoolean-001-n.js

raw symbols SCIP
1 /* -*- Mode: java; tab-width: 8 -*-
2 * Copyright (C) 1997, 1998 Netscape Communications Corporation,
3 * All Rights Reserved.
4 */
5 /* This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8
9 gTestfile = 'ToBoolean-001-n.js';
10
11 /**
12 * JavaScript to Java type conversion.
13 *
14 * This test passes JavaScript number values to several Java methods
15 * that expect arguments of various types, and verifies that the value is
16 * converted to the correct value and type.
17 *
18 * This tests instance methods, and not static methods.
19 *
20 * Running these tests successfully requires you to have
21 * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath.
22 *
23 * Specification: Method Overloading Proposal for Liveconnect 3.0
24 *
25 * @author: [email protected]
26 *
27 */
28 var SECTION = "JavaArray to boolean";
29 var VERSION = "1_4";
30 var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " +
31 SECTION;
32 startTest();
33
34 var dt = new DT();
35
36 var a = new Array();
37 var i = 0;
38
39 // Passing a JavaArray to a method that expects a boolean should
40 // always convert the array to true
41
42 var emptyByteArray = new java.lang.String("").getBytes();
43
44 a[i++] = new TestObject (
45 "dt.setBoolean( emptyByteArray )",
46 "dt.PUB_BOOLEAN ",
47 "dt.getBoolean() ",
48 "typeof dt.getBoolean() ",
49 true,
50 "boolean" );
51
52 a[i++] = new TestObject (
53 "dt.setBoolean( DT.staticGetByteArray() )",
54 "dt.PUB_BOOLEAN ",
55 "dt.getBoolean() ",
56 "typeof dt.getBoolean() ",
57 true,
58 "boolean" );
59 /*
60 a[i++] = new TestObject (
61 "dt.setBoolean( DT.staticGetByteArray() )",
62 "dt.PUB_BOOLEAN ",
63 "dt.getBoolean() ",
64 "typeof dt.getBoolean() ",
65 true,
66 "boolean" );
67
68 a[i++] = new TestObject (
69 "dt.setBoolean( DT.staticGetCharArray() )",
70 "dt.PUB_BOOLEAN ",
71 "dt.getBoolean() ",
72 "typeof dt.getBoolean() ",
73 true,
74 "boolean" );
75
76 a[i++] = new TestObject (
77 "dt.setBoolean( DT.staticGetShortArray() )",
78 "dt.PUB_BOOLEAN ",
79 "dt.getBoolean() ",
80 "typeof dt.getBoolean() ",
81 true,
82 "boolean" );
83
84 a[i++] = new TestObject (
85 "dt.setBoolean( DT.staticGetLongArray() )",
86 "dt.PUB_BOOLEAN ",
87 "dt.getBoolean() ",
88 "typeof dt.getBoolean() ",
89 true,
90 "boolean" );
91
92 a[i++] = new TestObject (
93 "dt.setBoolean( DT.staticGetIntArray() )",
94 "dt.PUB_BOOLEAN ",
95 "dt.getBoolean() ",
96 "typeof dt.getBoolean() ",
97 true,
98 "boolean" );
99
100 a[i++] = new TestObject (
101 "dt.setBoolean( DT.staticGetFloatArray() )",
102 "dt.PUB_BOOLEAN ",
103 "dt.getBoolean() ",
104 "typeof dt.getBoolean() ",
105 true,
106 "boolean" );
107
108 a[i++] = new TestObject (
109 "dt.setBoolean( DT.staticGetObjectArray() )",
110 "dt.PUB_BOOLEAN ",
111 "dt.getBoolean() ",
112 "typeof dt.getBoolean() ",
113 true,
114 "boolean" );
115 */
116 for ( i = 0; i < a.length; i++ ) {
117 new TestCase(
118 a[i].description +"; "+ a[i].javaFieldName,
119 a[i].jsValue,
120 a[i].javaFieldValue );
121
122 new TestCase(
123 a[i].description +"; " + a[i].javaMethodName,
124 a[i].jsValue,
125 a[i].javaMethodValue );
126
127 new TestCase(
128 a[i].javaTypeName,
129 a[i].jsType,
130 a[i].javaTypeValue );
131
132 }
133
134 test();
135
136 function TestObject( description, javaField, javaMethod, javaType,
137 jsValue, jsType )
138 {
139 eval (description );
140
141 this.description = description;
142 this.javaFieldName = javaField;
143 this.javaFieldValue = eval( javaField );
144 this.javaMethodName = javaMethod;
145 this.javaMethodValue = eval( javaMethod );
146 this.javaTypeName = javaType,
147 this.javaTypeValue = typeof this.javaFieldValue;
148
149 this.jsValue = jsValue;
150 this.jsType = jsType;
151 }