Debian Codegraph @

rhino/testsrc/tests/lc2/Packages/package-008-n.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 = 'package-008-n.js';
7
8 /**
9 File Name: package-008-n.js
10 Description:
11
12 Set the package name to a JavaScript variable, and attempt to access
13 classes relative to the package name.
14
15 @author [email protected]
16 @version 1.00
17 */
18 var SECTION = "LiveConnect Packages";
19 var VERSION = "1_3";
20 var TITLE = "LiveConnect Packages";
21
22 startTest();
23 writeHeaderToLog( SECTION + " "+ TITLE);
24
25 java.util[0] ="hi";
26 java.util["x"] = "bye";
27
28 new TestCase( SECTION,
29 "String(java.util[\"x\"])",
30 "[JavaPackage java.util.x]",
31 String(java.util["x"]) );
32 test();
33
34 function CompareValues( javaval, testval ) {
35 // Check typeof, which should be E_TYPE
36 new TestCase( SECTION,
37 "typeof (" + testval.description +")",
38 testval.type,
39 javaval.type );
40
41 // Check JavaScript class, which should be E_JSCLASS + the package name
42 new TestCase( SECTION,
43 "(" + testval.description +").getJSClass()",
44 testval.jsclass,
45 javaval.getJSClass() );
46
47 // Number( package ) is NaN
48 new TestCase( SECTION,
49 "Number (" + testval.description +")",
50 NaN,
51 Number( javaval ) );
52
53 // String( package ) is string value
54 new TestCase( SECTION,
55 "String (" + testval.description +")",
56 testval.jsclass,
57 String(javaval) );
58 // ( package ).toString() is string value
59 new TestCase( SECTION,
60 "(" + testval.description +").toString()",
61 testval.jsclass,
62 (javaval).toString() );
63
64 // Boolean( package ) is true
65 new TestCase( SECTION,
66 "Boolean (" + testval.description +")",
67 true,
68 Boolean( javaval ) );
69 // add 0 is name + "0"
70 new TestCase( SECTION,
71 "(" + testval.description +") +0",
72 testval.jsclass +"0",
73 javaval + 0);
74 }
75 function JavaValue( value ) {
76 this.value = value;
77 this.type = typeof value;
78 this.getJSClass = Object.prototype.toString;
79 this.jsclass = value +""
80 return this;
81 }
82 function TestValue( description ) {
83 this.packagename = (description.substring(0, "Packages.".length) ==
84 "Packages.") ? description.substring("Packages.".length, description.length ) :
85 description;
86
87 this.description = description;
88 this.type = E_TYPE;
89 this.jsclass = E_JSCLASS + this.packagename +"]";
90 return this;
91 }