Debian Codegraph @

rhino/testsrc/tests/lc3/CallStatic/number-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 = 'number-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.staticSetByte( 99 )",
35 "dt.PUB_STATIC_BYTE",
36 "dt.staticGetByte()",
37 "typeof dt.staticGetByte()",
38 99,
39 "number" );
40
41 a[i++] = new TestObject(
42 "dt.staticSetChar( 45678 )",
43 "dt.PUB_STATIC_CHAR",
44 "dt.staticGetChar()",
45 "typeof dt.staticGetChar()",
46 45678,
47 "number" );
48
49 a[i++] = new TestObject(
50 "dt.staticSetShort( 32109 )",
51 "dt.PUB_STATIC_SHORT",
52 "dt.staticGetShort()",
53 "typeof dt.staticGetShort()",
54 32109,
55 "number" );
56
57 a[i++] = new TestObject(
58 "dt.staticSetInteger( 2109876543 )",
59 "dt.PUB_STATIC_INT",
60 "dt.staticGetInteger()",
61 "typeof dt.staticGetInteger()",
62 2109876543,
63 "number" );
64
65 a[i++] = new TestObject(
66 "dt.staticSetLong( 9012345678901234567 )",
67 "dt.PUB_STATIC_LONG",
68 "dt.staticGetLong()",
69 "typeof dt.staticGetLong()",
70 9012345678901234567,
71 "number" );
72
73
74 a[i++] = new TestObject(
75 "dt.staticSetDouble( java.lang.Double.MIN_VALUE )",
76 "dt.PUB_STATIC_DOUBLE",
77 "dt.staticGetDouble()",
78 "typeof dt.staticGetDouble()",
79 java.lang.Double.MIN_VALUE,
80 "number" );
81
82 a[i++] = new TestObject(
83 "dt.staticSetFloat( java.lang.Float.MIN_VALUE )",
84 "dt.PUB_STATIC_FLOAT",
85 "dt.staticGetFloat()",
86 "typeof dt.staticGetFloat()",
87 java.lang.Float.MIN_VALUE,
88 "number" );
89
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 }