Debian Codegraph @

rhino/testsrc/tests/lc2/Packages/package-007-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-007-n.js';
7
8 /**
9 File Name: package-007-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 "java.util[0] = \"hi\"; typeof java.util[0]",
30 "undefined",
31 typeof java.util[0] );
32
33 test();
34
35 function CompareValues( javaval, testval ) {
36 // Check typeof, which should be E_TYPE
37 new TestCase( SECTION,
38 "typeof (" + testval.description +")",
39 testval.type,
40 javaval.type );
41
42 // Check JavaScript class, which should be E_JSCLASS + the package name
43 new TestCase( SECTION,
44 "(" + testval.description +").getJSClass()",
45 testval.jsclass,
46 javaval.getJSClass() );
47
48 // Number( package ) is NaN
49 new TestCase( SECTION,
50 "Number (" + testval.description +")",
51 NaN,
52 Number( javaval ) );
53
54 // String( package ) is string value
55 new TestCase( SECTION,
56 "String (" + testval.description +")",
57 testval.jsclass,
58 String(javaval) );
59 // ( package ).toString() is string value
60 new TestCase( SECTION,
61 "(" + testval.description +").toString()",
62 testval.jsclass,
63 (javaval).toString() );
64
65 // Boolean( package ) is true
66 new TestCase( SECTION,
67 "Boolean (" + testval.description +")",
68 true,
69 Boolean( javaval ) );
70 // add 0 is name + "0"
71 new TestCase( SECTION,
72 "(" + testval.description +") +0",
73 testval.jsclass +"0",
74 javaval + 0);
75 }
76 function JavaValue( value ) {
77 this.value = value;
78 this.type = typeof value;
79 this.getJSClass = Object.prototype.toString;
80 this.jsclass = value +""
81 return this;
82 }
83 function TestValue( description ) {
84 this.packagename = (description.substring(0, "Packages.".length) ==
85 "Packages.") ? description.substring("Packages.".length, description.length ) :
86 description;
87
88 this.description = description;
89 this.type = E_TYPE;
90 this.jsclass = E_JSCLASS + this.packagename +"]";
91 return this;
92 }