Debian Codegraph @

rhino/testsrc/tests/lc3/CallStatic/object-001.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = 'object-001.js';
7
8 /**
9 * The Java language allows static methods to be invoked using either the
10 * class name or a reference to an instance of the class, but previous
11 * versions of liveocnnect only allowed the former.
12 *
13 * Verify that we can call static methods and get the value of static fields
14 * from an instance reference.
15 *
16 * author: [email protected]
17 *
18 * date: 12/9/1998
19 *
20 */
21 var SECTION = "Call static methods from an instance";
22 var VERSION = "1_4";
23 var TITLE = "LiveConnect 3.0 " +
24 SECTION;
25 startTest();
26
27 var DT = Packages.com.netscape.javascript.qa.liveconnect.DataTypeClass;
28 var dt = new DT();
29
30 var a = new Array;
31 var i = 0;
32
33 a[i++] = new TestObject(
34 "dt.staticSetDoubleObject( 99 )",
35 "dt.PUB_STATIC_DOUBLE_OBJECT.doubleValue()",
36 "dt.staticGetDoubleObject().doubleValue()",
37 "dt.staticGetDoubleObject().getClass().getName() +''",
38 99,
39 "java.lang.Double" );
40
41 a[i++] = new TestObject(
42 "dt.staticSetShortObject( new java.lang.Short(32109) )",
43 "dt.PUB_STATIC_SHORT_OBJECT.doubleValue()",
44 "dt.staticGetShortObject().doubleValue()",
45 "dt.staticGetShortObject().getClass().getName() +''",
46 32109,
47 "java.lang.Short" );
48
49 a[i++] = new TestObject(
50 "dt.staticSetIntegerObject( new java.lang.Integer(2109876543) )",
51 "dt.PUB_STATIC_INTEGER_OBJECT.doubleValue()",
52 "dt.staticGetIntegerObject().doubleValue()",
53 "dt.staticGetIntegerObject().getClass().getName() +''",
54 2109876543,
55 "java.lang.Integer" );
56
57
58 a[i++] = new TestObject(
59 "dt.staticSetLongObject( new java.lang.Long(9012345678901234567) )",
60 "dt.PUB_STATIC_LONG_OBJECT.doubleValue()",
61 "dt.staticGetLongObject().doubleValue()",
62 "dt.staticGetLongObject().getClass().getName() +''",
63 9012345678901234567,
64 "java.lang.Long" );
65
66
67 a[i++] = new TestObject(
68 "dt.staticSetDoubleObject(new java.lang.Double( java.lang.Double.MIN_VALUE) )",
69 "dt.PUB_STATIC_DOUBLE_OBJECT.doubleValue()",
70 "dt.staticGetDoubleObject().doubleValue()",
71 "dt.staticGetDoubleObject().getClass().getName()+''",
72 java.lang.Double.MIN_VALUE,
73 "java.lang.Double" );
74
75 a[i++] = new TestObject(
76 "dt.staticSetFloatObject( new java.lang.Float(java.lang.Float.MIN_VALUE) )",
77 "dt.PUB_STATIC_FLOAT_OBJECT.doubleValue()",
78 "dt.staticGetFloatObject().doubleValue()",
79 "dt.staticGetFloatObject().getClass().getName() +''",
80 java.lang.Float.MIN_VALUE,
81 "java.lang.Float" );
82
83 a[i++] = new TestObject(
84 "dt.staticSetCharacter( new java.lang.Character(45678) )",
85 "dt.PUB_STATIC_CHAR_OBJECT.charValue()",
86 "dt.staticGetCharacter().charValue()",
87 "dt.staticGetCharacter().getClass().getName()+''",
88 45678,
89 "java.lang.Character" );
90
91 for ( i = 0; i < a.length; i++ ) {
92 new TestCase(
93 a[i].description +"; "+ a[i].javaFieldName,
94 a[i].jsValue,
95 a[i].javaFieldValue );
96
97 new TestCase(
98 a[i].description +"; " + a[i].javaMethodName,
99 a[i].jsValue,
100 a[i].javaMethodValue );
101
102 new TestCase(
103 a[i].javaTypeName,
104 a[i].jsType,
105 a[i].javaTypeValue );
106 }
107
108 test();
109
110 function TestObject( description, javaField, javaMethod, javaType,
111 jsValue, jsType )
112 {
113 eval (description );
114
115 this.description = description;
116 this.javaFieldName = javaField;
117 this.javaFieldValue = eval( javaField );
118 this.javaMethodName = javaMethod;
119 this.javaMethodValue = eval( javaMethod );
120 this.javaTypeName = javaType,
121 this.javaTypeValue = eval( javaType );
122
123 this.jsValue = jsValue;
124 this.jsType = jsType;
125 }