Debian Codegraph @

rhino/testsrc/tests/lc2/Packages/package-002.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-002.js';
7
8 /**
9 File Name: package-001.js
10 Description:
11
12 Use package names that are not in the classpath.
13
14 @author [email protected]
15 @version 1.00
16 */
17 var SECTION = "LiveConnect Packages";
18 var VERSION = "1_3";
19 var TITLE = "LiveConnect Packages";
20
21 startTest();
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24 // All packages are of the type "object"
25 var E_TYPE = "object";
26
27 // The JavaScript [[Class]] property for all Packages is "[JavaPackage <packagename>]"
28 var E_JSCLASS = "[JavaPackage ";
29
30 // Create arrays of actual results (java_array) and
31 // expected results (test_array).
32
33 var java_array = new Array();
34 var test_array = new Array();
35
36 var i = 0;
37
38 java_array[i] = new JavaValue( java.bad.packagename );
39 test_array[i] = new TestValue( "java.bad.packagename" );
40 i++;
41
42
43 java_array[i] = new JavaValue( Packages.javax.badpackage );
44 test_array[i] = new TestValue( "Packages.javax.badpackage" );
45 i++;
46
47
48 for ( i = 0; i < java_array.length; i++ ) {
49 CompareValues( java_array[i], test_array[i] );
50
51 }
52
53 test();
54 function CompareValues( javaval, testval ) {
55 // Check typeof, which should be E_TYPE
56 new TestCase( SECTION,
57 "typeof (" + testval.description +")",
58 testval.type,
59 javaval.type );
60
61 // Check JavaScript class, which should be E_JSCLASS + the package name
62 new TestCase( SECTION,
63 "(" + testval.description +").getJSClass()",
64 testval.jsclass,
65 javaval.jsclass );
66 }
67 function JavaValue( value ) {
68 this.value = value;
69 this.type = typeof value;
70 this.jsclass = value +""
71 return this;
72 }
73 function TestValue( description ) {
74 this.packagename = (description.substring(0, "Packages.".length) ==
75 "Packages.") ? description.substring("Packages.".length, description.length ) :
76 description;
77
78 this.description = description;
79 this.type = E_TYPE;
80 this.jsclass = E_JSCLASS + this.packagename +"]";
81 return this;
82 }