Debian Codegraph @

rhino/testsrc/tests/lc3/JSObject/ToDouble-002-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 = 'ToDouble-002-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 = "JavaScript Object to java.lang.String";
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 DESCRIPTION = "dt.setDouble(void 0)";
40 EXPECTED = "error";
41
42 a[i++] = new TestObject(
43 "dt.setDouble(void 0)",
44 "dt.PUB_DOUBLE",
45 "dt.getDouble()",
46 "typeof dt.getDouble()",
47 "error",
48 "error");
49
50 for ( i = 0; i < a.length; i++ ) {
51 new TestCase(
52 a[i].description +"; "+ a[i].javaFieldName,
53 a[i].jsValue,
54 a[i].javaFieldValue );
55
56 new TestCase(
57 a[i].description +"; " + a[i].javaMethodName,
58 a[i].jsValue,
59 a[i].javaMethodValue );
60
61 new TestCase(
62 a[i].javaTypeName,
63 a[i].jsType,
64 a[i].javaTypeValue );
65 }
66
67 test();
68
69 function MyObject( stringValue ) {
70 this.stringValue = String(stringValue);
71 this.toString = new Function( "return this.stringValue" );
72 }
73
74 function MyOtherObject( value ) {
75 this.toString = null;
76 this.value = value;
77 this.valueOf = new Function( "return this.value" );
78 }
79
80 function AnotherObject( value ) {
81 this.toString = new Function( "return new Number(666)" );
82 this.value = value;
83 this.valueOf = new Function( "return this.value" );
84 }
85
86 function TestObject( description, javaField, javaMethod, javaType,
87 jsValue, jsType )
88 {
89 eval (description );
90
91 this.description = description;
92 this.javaFieldName = javaField;
93 this.javaFieldValue = eval( javaField );
94 this.javaMethodName = javaMethod;
95 this.javaMethodValue = eval( javaMethod );
96 this.javaTypeName = javaType,
97 this.javaTypeValue = eval( javaType );
98
99 this.jsValue = jsValue;
100 this.jsType = jsType;
101 }