Debian Codegraph @

rhino/testsrc/tests/lc2/Packages/package-005.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-005.js';
7
8 /**
9 File Name: package-005.js
10 Description:
11
12 Access a package property that does not exist.
13
14 @author [email protected]
15 @version 1.00
16 */
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 var util = java.util;
26 var v = new util.Vector();
27
28 new TestCase( SECTION,
29 "java.util[\"0\"]",
30 void 0,
31 java.util["0"] );
32
33
34 new TestCase( SECTION,
35 "java.util[1]",
36 void 0,
37 java.util[1] );
38
39 test();
40
41 function CompareValues( javaval, testval ) {
42 // Check typeof, which should be E_TYPE
43 new TestCase( SECTION,
44 "typeof (" + testval.description +")",
45 testval.type,
46 javaval.type );
47
48 // Check JavaScript class, which should be E_JSCLASS + the package name
49 new TestCase( SECTION,
50 "(" + testval.description +").getJSClass()",
51 testval.jsclass,
52 javaval.getJSClass() );
53
54 // Number( package ) is NaN
55 new TestCase( SECTION,
56 "Number (" + testval.description +")",
57 NaN,
58 Number( javaval ) );
59
60 // String( package ) is string value
61 new TestCase( SECTION,
62 "String (" + testval.description +")",
63 testval.jsclass,
64 String(javaval) );
65 // ( package ).toString() is string value
66 new TestCase( SECTION,
67 "(" + testval.description +").toString()",
68 testval.jsclass,
69 (javaval).toString() );
70
71 // Boolean( package ) is true
72 new TestCase( SECTION,
73 "Boolean (" + testval.description +")",
74 true,
75 Boolean( javaval ) );
76 // add 0 is name + "0"
77 new TestCase( SECTION,
78 "(" + testval.description +") +0",
79 testval.jsclass +"0",
80 javaval + 0);
81 }
82 function JavaValue( value ) {
83 this.value = value;
84 this.type = typeof value;
85 this.getJSClass = Object.prototype.toString;
86 this.jsclass = value +""
87 return this;
88 }
89 function TestValue( description ) {
90 this.packagename = (description.substring(0, "Packages.".length) ==
91 "Packages.") ? description.substring("Packages.".length, description.length ) :
92 description;
93
94 this.description = description;
95 this.type = E_TYPE;
96 this.jsclass = E_JSCLASS + this.packagename +"]";
97 return this;
98 }