Debian Codegraph @

rhino/testsrc/tests/lc3/JavaClass/ToJSObject-001.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 = 'ToJSObject-001.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 = "JavaClass to java.lang.Class";
29 var VERSION = "1_4";
30 var TITLE = "LiveConnect 3.0 JavaScript to Java Data Type Conversion " +
31 SECTION;
32
33 var BUGNUMBER ="335885";
34
35 startTest();
36
37 var jsoc = new
38 Packages.com.netscape.javascript.qa.liveconnect.JSObjectConversion();
39
40 var a = new Array();
41 var i = 0;
42
43 // Pass a JavaClass to a method that expects a JSObject should wrap
44 // the object in a new instance of JSObject.
45
46 a[i++] = new TestObject (
47 "var newClass = java.lang.Integer; "+
48 "jsoc.setJSObject( newClass )",
49 "jsoc.PUB_JSOBJECT",
50 "jsoc.getJSObject()",
51 "jsoc.getJSObject()",
52 java.lang.Integer,
53 "function" );
54
55
56 for ( i = 0; i < a.length; i++ ) {
57 new TestCase(
58 a[i].description +"; "+ a[i].javaFieldName,
59 a[i].jsValue,
60 a[i].javaFieldValue );
61
62 new TestCase(
63 a[i].description +"; " + a[i].javaMethodName,
64 a[i].jsValue,
65 a[i].javaMethodValue );
66
67 new TestCase(
68 a[i].javaTypeName,
69 a[i].jsType,
70 a[i].javaTypeValue );
71
72 }
73
74 test();
75
76 function TestObject( description, javaField, javaMethod, javaType,
77 jsValue, jsType )
78 {
79 eval (description );
80
81 this.description = description;
82 this.javaFieldName = javaField;
83 this.javaFieldValue = eval( javaField );
84 this.javaMethodName = javaMethod;
85 this.javaMethodValue = eval( javaMethod );
86 this.javaTypeName = javaType,
87 this.javaTypeValue = typeof this.javaFieldValue;
88
89 this.jsValue = jsValue;
90 this.jsType = jsType;
91 }