Follow-on fix for bug 457825. Use sheet principal for agent and user sheets. r=dbaron...
[wine-gecko.git] / js / tests / lc3 / JSNumber / ToDouble-001.js
blob13140ff7a074da8a84f7a778c86ab363948f46a2
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Mozilla Communicator client code, released
16 * March 31, 1998.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 gTestfile = 'ToDouble-001.js';
41 /* -*- Mode: java; tab-width: 8 -*-
42 * Copyright (C) 1997, 1998 Netscape Communications Corporation,
43 * All Rights Reserved.
46 /**
47 * JavaScript to Java type conversion.
49 * This test passes JavaScript number values to several Java methods
50 * that expect arguments of various types, and verifies that the value is
51 * converted to the correct value and type.
53 * This tests instance methods, and not static methods.
55 * Running these tests successfully requires you to have
56 * com.netscape.javascript.qa.liveconnect.DataTypeClass on your classpath.
58 * Specification: Method Overloading Proposal for Liveconnect 3.0
60 * @author: christine@netscape.com
63 var SECTION = "number conversion";
64 var VERSION = "1_4";
65 var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " +
66 SECTION;
67 startTest();
69 var dt = new DT();
71 var a = new Array();
72 var i = 0;
74 // passing a number to a java method that expects a double should
75 // transfer the exact value to java with no rounding or loss of magnitude
76 // or sign.
78 // Special cases: 0, -0, Infinity, -Infinity, and NaN
80 a[i++] = new TestObject(
81 "dt.setDouble( 0 )",
82 "dt.PUB_DOUBLE",
83 "dt.getDouble()",
84 "typeof dt.getDouble()",
86 "number" );
88 a[i++] = new TestObject(
89 "dt.setDouble( -0 )",
90 "Infinity / dt.PUB_DOUBLE",
91 "Infinity / dt.getDouble()",
92 "typeof dt.getDouble()",
93 -Infinity,
94 "number" );
96 a[i++] = new TestObject(
97 "dt.setDouble( Infinity )",
98 "dt.PUB_DOUBLE ",
99 "dt.getDouble() ",
100 "typeof dt.getDouble()",
101 Infinity,
102 "number" );
104 a[i++] = new TestObject(
105 "dt.setDouble( -Infinity )",
106 "dt.PUB_DOUBLE",
107 "dt.getDouble() ",
108 "typeof dt.getDouble()",
109 -Infinity,
110 "number" );
112 a[i++] = new TestObject(
113 "dt.setDouble( NaN )",
114 "dt.PUB_DOUBLE",
115 "dt.getDouble()",
116 "typeof dt.getDouble()",
117 NaN,
118 "number" );
120 // test cases from waldemar
122 a[i++] = new TestObject(
123 "dt.setDouble(077777777777777777)",
124 "dt.PUB_DOUBLE",
125 "dt.getDouble()",
126 "typeof dt.getDouble()",
127 2251799813685247,
128 "number" );
131 a[i++] = new TestObject(
132 "dt.setDouble(077777777777777776)",
133 "dt.PUB_DOUBLE",
134 "dt.getDouble()",
135 "typeof dt.getDouble()",
136 2251799813685246,
137 "number" );
140 a[i++] = new TestObject(
141 "dt.setDouble(0x1fffffffffffff)",
142 "dt.PUB_DOUBLE",
143 "dt.getDouble()",
144 "typeof dt.getDouble()",
145 9007199254740991,
146 "number" );
148 a[i++] = new TestObject(
149 "dt.setDouble(0x20000000000000)",
150 "dt.PUB_DOUBLE",
151 "dt.getDouble()",
152 "typeof dt.getDouble()",
153 9007199254740992,
154 "number" );
156 a[i++] = new TestObject(
157 "dt.setDouble(0x20123456789abc)",
158 "dt.PUB_DOUBLE",
159 "dt.getDouble()",
160 "typeof dt.getDouble()",
161 9027215253084860,
162 "number" );
164 a[i++] = new TestObject(
165 "dt.setDouble(0x20123456789abd)",
166 "dt.PUB_DOUBLE",
167 "dt.getDouble()",
168 "typeof dt.getDouble()",
169 9027215253084860,
170 "number" );
172 a[i++] = new TestObject(
173 "dt.setDouble(0x20123456789abe)",
174 "dt.PUB_DOUBLE",
175 "dt.getDouble()",
176 "typeof dt.getDouble()",
177 9027215253084862,
178 "number" );
180 a[i++] = new TestObject(
181 "dt.setDouble(0x20123456789abf)",
182 "dt.PUB_DOUBLE",
183 "dt.getDouble()",
184 "typeof dt.getDouble()",
185 9027215253084864,
186 "number" );
188 a[i++] = new TestObject(
189 "dt.setDouble(0x1000000000000080)",
190 "dt.PUB_DOUBLE",
191 "dt.getDouble()",
192 "typeof dt.getDouble()",
193 1152921504606847000,
194 "number" );
196 a[i++] = new TestObject(
197 "dt.setDouble(0x1000000000000081)",
198 "dt.PUB_DOUBLE",
199 "dt.getDouble()",
200 "typeof dt.getDouble()",
201 1152921504606847200,
202 "number" );
204 a[i++] = new TestObject(
205 "dt.setDouble(0x1000000000000100)",
206 "dt.PUB_DOUBLE",
207 "dt.getDouble()",
208 "typeof dt.getDouble()",
209 1152921504606847200,
210 "number" );
212 a[i++] = new TestObject(
213 "dt.setDouble(0x100000000000017f)",
214 "dt.PUB_DOUBLE",
215 "dt.getDouble()",
216 "typeof dt.getDouble()",
217 1152921504606847200,
218 "number" );
220 a[i++] = new TestObject(
221 "dt.setDouble(0x1000000000000180)",
222 "dt.PUB_DOUBLE",
223 "dt.getDouble()",
224 "typeof dt.getDouble()",
225 1152921504606847500,
226 "number" );
228 a[i++] = new TestObject(
229 "dt.setDouble(0x1000000000000181)",
230 "dt.PUB_DOUBLE",
231 "dt.getDouble()",
232 "typeof dt.getDouble()",
233 1152921504606847500,
234 "number" );
236 a[i++] = new TestObject(
237 "dt.setDouble(1.7976931348623157E+308)",
238 "dt.PUB_DOUBLE",
239 "dt.getDouble()",
240 "typeof dt.getDouble()",
241 1.7976931348623157e+308,
242 "number" );
244 a[i++] = new TestObject(
245 "dt.setDouble(1.7976931348623158e+308)",
246 "dt.PUB_DOUBLE",
247 "dt.getDouble()",
248 "typeof dt.getDouble()",
249 1.7976931348623157e+308,
250 "number" );
252 a[i++] = new TestObject(
253 "dt.setDouble(1.7976931348623159e+308)",
254 "dt.PUB_DOUBLE",
255 "dt.getDouble()",
256 "typeof dt.getDouble()",
257 Infinity,
258 "number" );
260 a[i++] = new TestObject(
261 "dt.setDouble(-1.7976931348623157E+308)",
262 "dt.PUB_DOUBLE",
263 "dt.getDouble()",
264 "typeof dt.getDouble()",
265 -1.7976931348623157e+308,
266 "number" );
268 a[i++] = new TestObject(
269 "dt.setDouble(-1.7976931348623158e+308)",
270 "dt.PUB_DOUBLE",
271 "dt.getDouble()",
272 "typeof dt.getDouble()",
273 -1.7976931348623157e+308,
274 "number" );
276 a[i++] = new TestObject(
277 "dt.setDouble(-1.7976931348623159e+308)",
278 "dt.PUB_DOUBLE",
279 "dt.getDouble()",
280 "typeof dt.getDouble()",
281 -Infinity,
282 "number" );
284 a[i++] = new TestObject(
285 "dt.setDouble(1e-2000)",
286 "dt.PUB_DOUBLE",
287 "dt.getDouble()",
288 "typeof dt.getDouble()",
290 "number" );
292 a[i++] = new TestObject(
293 "dt.setDouble(1e2000)",
294 "dt.PUB_DOUBLE",
295 "dt.getDouble()",
296 "typeof dt.getDouble()",
297 1e2000,
298 "number" );
300 a[i++] = new TestObject(
301 "dt.setDouble(-1e2000)",
302 "dt.PUB_DOUBLE",
303 "dt.getDouble()",
304 "typeof dt.getDouble()",
305 -1e2000,
306 "number" );
308 for ( i = 0; i < a.length; i++ ) {
309 new TestCase(
310 a[i].description +"; "+ a[i].javaFieldName,
311 a[i].jsValue,
312 a[i].javaFieldValue );
314 new TestCase(
315 a[i].description +"; " + a[i].javaMethodName,
316 a[i].jsValue,
317 a[i].javaMethodValue );
319 new TestCase(
320 a[i].javaTypeName,
321 a[i].jsType,
322 a[i].javaTypeValue );
325 test();
327 function TestObject( description, javaField, javaMethod, javaType,
328 jsValue, jsType )
330 eval (description );
332 this.description = description;
333 this.javaFieldName = javaField;
334 this.javaFieldValue = eval( javaField );
335 this.javaMethodName = javaMethod;
336 this.javaMethodValue = eval( javaMethod );
337 this.javaTypeName = javaType,
338 this.javaTypeValue = eval( javaType );
340 this.jsValue = jsValue;
341 this.jsType = jsType;