Follow-on fix for bug 457825. Use sheet principal for agent and user sheets. r=dbaron...
[wine-gecko.git] / js / tests / lc3 / JavaArray / ToBoolean-001-n.js
blob91449c21839040b93744db85685dc34e437c7e66
1 /* -*- Mode: java; tab-width: 8 -*-
2 * Copyright (C) 1997, 1998 Netscape Communications Corporation,
3 * All Rights Reserved.
4 */
5 /* ***** BEGIN LICENSE BLOCK *****
6 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
8 * The contents of this file are subject to the Mozilla Public License Version
9 * 1.1 (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at
11 * http://www.mozilla.org/MPL/
13 * Software distributed under the License is distributed on an "AS IS" basis,
14 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
15 * for the specific language governing rights and limitations under the
16 * License.
18 * The Original Code is Mozilla Communicator client code, released
19 * March 31, 1998.
21 * The Initial Developer of the Original Code is
22 * Netscape Communications Corporation.
23 * Portions created by the Initial Developer are Copyright (C) 1998
24 * the Initial Developer. All Rights Reserved.
26 * Contributor(s):
28 * Alternatively, the contents of this file may be used under the terms of
29 * either the GNU General Public License Version 2 or later (the "GPL"), or
30 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 * in which case the provisions of the GPL or the LGPL are applicable instead
32 * of those above. If you wish to allow use of your version of this file only
33 * under the terms of either the GPL or the LGPL, and not to allow others to
34 * use your version of this file under the terms of the MPL, indicate your
35 * decision by deleting the provisions above and replace them with the notice
36 * and other provisions required by the GPL or the LGPL. If you do not delete
37 * the provisions above, a recipient may use your version of this file under
38 * the terms of any one of the MPL, the GPL or the LGPL.
40 * ***** END LICENSE BLOCK ***** */
42 gTestfile = 'ToBoolean-001-n.js';
44 /**
45 * JavaScript to Java type conversion.
47 * This test passes JavaScript number values to several Java methods
48 * that expect arguments of various types, and verifies that the value is
49 * converted to the correct value and type.
51 * This tests instance methods, and not static methods.
53 * Running these tests successfully requires you to have
54 * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath.
56 * Specification: Method Overloading Proposal for Liveconnect 3.0
58 * @author: christine@netscape.com
61 var SECTION = "JavaArray to boolean";
62 var VERSION = "1_4";
63 var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " +
64 SECTION;
65 startTest();
67 var dt = new DT();
69 var a = new Array();
70 var i = 0;
72 // Passing a JavaArray to a method that expects a boolean should
73 // always convert the array to true
75 var emptyByteArray = new java.lang.String("").getBytes();
77 a[i++] = new TestObject (
78 "dt.setBoolean( emptyByteArray )",
79 "dt.PUB_BOOLEAN ",
80 "dt.getBoolean() ",
81 "typeof dt.getBoolean() ",
82 true,
83 "boolean" );
85 a[i++] = new TestObject (
86 "dt.setBoolean( DT.staticGetByteArray() )",
87 "dt.PUB_BOOLEAN ",
88 "dt.getBoolean() ",
89 "typeof dt.getBoolean() ",
90 true,
91 "boolean" );
93 a[i++] = new TestObject (
94 "dt.setBoolean( DT.staticGetByteArray() )",
95 "dt.PUB_BOOLEAN ",
96 "dt.getBoolean() ",
97 "typeof dt.getBoolean() ",
98 true,
99 "boolean" );
101 a[i++] = new TestObject (
102 "dt.setBoolean( DT.staticGetCharArray() )",
103 "dt.PUB_BOOLEAN ",
104 "dt.getBoolean() ",
105 "typeof dt.getBoolean() ",
106 true,
107 "boolean" );
109 a[i++] = new TestObject (
110 "dt.setBoolean( DT.staticGetShortArray() )",
111 "dt.PUB_BOOLEAN ",
112 "dt.getBoolean() ",
113 "typeof dt.getBoolean() ",
114 true,
115 "boolean" );
117 a[i++] = new TestObject (
118 "dt.setBoolean( DT.staticGetLongArray() )",
119 "dt.PUB_BOOLEAN ",
120 "dt.getBoolean() ",
121 "typeof dt.getBoolean() ",
122 true,
123 "boolean" );
125 a[i++] = new TestObject (
126 "dt.setBoolean( DT.staticGetIntArray() )",
127 "dt.PUB_BOOLEAN ",
128 "dt.getBoolean() ",
129 "typeof dt.getBoolean() ",
130 true,
131 "boolean" );
133 a[i++] = new TestObject (
134 "dt.setBoolean( DT.staticGetFloatArray() )",
135 "dt.PUB_BOOLEAN ",
136 "dt.getBoolean() ",
137 "typeof dt.getBoolean() ",
138 true,
139 "boolean" );
141 a[i++] = new TestObject (
142 "dt.setBoolean( DT.staticGetObjectArray() )",
143 "dt.PUB_BOOLEAN ",
144 "dt.getBoolean() ",
145 "typeof dt.getBoolean() ",
146 true,
147 "boolean" );
149 for ( i = 0; i < a.length; i++ ) {
150 new TestCase(
151 a[i].description +"; "+ a[i].javaFieldName,
152 a[i].jsValue,
153 a[i].javaFieldValue );
155 new TestCase(
156 a[i].description +"; " + a[i].javaMethodName,
157 a[i].jsValue,
158 a[i].javaMethodValue );
160 new TestCase(
161 a[i].javaTypeName,
162 a[i].jsType,
163 a[i].javaTypeValue );
167 test();
169 function TestObject( description, javaField, javaMethod, javaType,
170 jsValue, jsType )
172 eval (description );
174 this.description = description;
175 this.javaFieldName = javaField;
176 this.javaFieldValue = eval( javaField );
177 this.javaMethodName = javaMethod;
178 this.javaMethodValue = eval( javaMethod );
179 this.javaTypeName = javaType,
180 this.javaTypeValue = typeof this.javaFieldValue;
182 this.jsValue = jsValue;
183 this.jsType = jsType;