Bug 469739 - Add support for displaying Vista UAC shield icon; r=joe sr=vladimir
[wine-gecko.git] / js / tests / lc2 / JSToJava / double-002.js
blob15c4614a8ab936f994941721b157805aabfd56aa
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 = 'double-002.js';
41 /**
42 Template for LiveConnect Tests
44 File Name: number-001.js
45 Description:
47 When setting the value of a Java field with a JavaScript number or
48 when passing a JavaScript number to a Java method as an argument,
49 LiveConnect should be able to convert the number to any one of the
50 following types:
52 byte
53 short
54 int
55 long
56 float
57 double
58 char
59 java.lang.Double
61 Note that the value of the Java field may not be as precise as the
62 JavaScript value's number, if for example, you pass a large number to
63 a short or byte, or a float to integer.
65 JavaScript numbers cannot be converted to instances of java.lang.Float
66 or java.lang.Integer.
68 This test does not cover the cases in which a Java method returns one
69 of the above primitive Java types.
71 Currently split up into numerous tests, since rhino live connect fails
72 to translate numbers into the correct types.
74 Test for passing JavasScript numbers to static java.lang.Integer methods.
77 @author christine@netscape.com
78 @version 1.00
80 var SECTION = "double-001";
81 var VERSION = "1_3";
82 var TITLE = "LiveConnect JavaScript to Java Data Type Conversion";
84 startTest();
85 writeHeaderToLog( SECTION + " "+ TITLE);
87 // typeof all resulting objects is "object";
88 var E_TYPE = "object";
90 // JS class of all resulting objects is "JavaObject";
91 var E_JSCLASS = "[object JavaObject]";
93 var a = new Array();
94 var i = 0;
96 a[i++] = new TestObject( "java.lang.Double.toString(0)",
97 java.lang.Double.toString(0), "0.0" );
99 a[i++] = new TestObject( "java.lang.Double.toString(NaN)",
100 java.lang.Double.toString(NaN), "NaN" );
102 a[i++] = new TestObject( "java.lang.Double.toString(5)",
103 java.lang.Double.toString(5), "5.0" );
105 a[i++] = new TestObject( "java.lang.Double.toString(9.9)",
106 java.lang.Double.toString(9.9), "9.9" );
108 a[i++] = new TestObject( "java.lang.Double.toString(-9.9)",
109 java.lang.Double.toString(-9.9), "-9.9" );
111 for ( var i = 0; i < a.length; i++ ) {
113 // check typeof
114 new TestCase(
115 SECTION,
116 "typeof (" + a[i].description +")",
117 a[i].type,
118 typeof a[i].javavalue );
120 // check the js class
121 new TestCase(
122 SECTION,
123 "("+ a[i].description +").getJSClass()",
124 E_JSCLASS,
125 a[i].jsclass );
127 // check the number value of the object
128 new TestCase(
129 SECTION,
130 "String(" + a[i].description +")",
131 a[i].jsvalue,
132 String( a[i].javavalue ) );
135 test();
137 function TestObject( description, javavalue, jsvalue ) {
138 this.description = description;
139 this.javavalue = javavalue;
140 this.jsvalue = jsvalue;
141 this.type = E_TYPE;
142 // LC2 does not support the proto property in Java objects
143 // this.javavalue.__proto__.getJSClass = Object.prototype.toString;
144 // this.jsclass = this.javavalue.getJSClass();
145 return this;