Debian Codegraph @

rhino/testsrc/tests/ecma_3/Object/class-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 /*
7 * Date: 14 Mar 2001
8 *
9 * SUMMARY: Testing the internal [[Class]] property of objects
10 * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2
11 *
12 * The getJSClass() function we use is in a utility file, e.g. "shell.js".
13 */
14 //-----------------------------------------------------------------------------
15 var gTestfile = 'class-001.js';
16 var i = 0;
17 var UBound = 0;
18 var BUGNUMBER = '(none)';
19 var summary = 'Testing the internal [[Class]] property of objects';
20 var statprefix = 'Current object is: ';
21 var status = ''; var statusList = [ ];
22 var actual = ''; var actualvalue = [ ];
23 var expect= ''; var expectedvalue = [ ];
24
25
26 status = 'the global object';
27 actual = getJSClass(this);
28 expect = GLOBAL;
29 if (expect == 'Window' && actual == 'XPCCrossOriginWrapper')
30 {
31 print('Skipping global object due to XPCCrossOriginWrapper. See bug 390946');
32 }
33 else
34 {
35 addThis();
36 }
37
38 status = 'new Object()';
39 actual = getJSClass(new Object());
40 expect = 'Object';
41 addThis();
42
43 status = 'new Function()';
44 actual = getJSClass(new Function());
45 expect = 'Function';
46 addThis();
47
48 status = 'new Array()';
49 actual = getJSClass(new Array());
50 expect = 'Array';
51 addThis();
52
53 status = 'new String()';
54 actual = getJSClass(new String());
55 expect = 'String';
56 addThis();
57
58 status = 'new Boolean()';
59 actual = getJSClass(new Boolean());
60 expect = 'Boolean';
61 addThis();
62
63 status = 'new Number()';
64 actual = getJSClass(new Number());
65 expect = 'Number';
66 addThis();
67
68 status = 'Math';
69 actual = getJSClass(Math); // can't use 'new' with the Math object (EMCA3, 15.8)
70 expect = 'Math';
71 addThis();
72
73 status = 'new Date()';
74 actual = getJSClass(new Date());
75 expect = 'Date';
76 addThis();
77
78 status = 'new RegExp()';
79 actual = getJSClass(new RegExp());
80 expect = 'RegExp';
81 addThis();
82
83 status = 'new Error()';
84 actual = getJSClass(new Error());
85 expect = 'Error';
86 addThis();
87
88
89
90 //---------------------------------------------------------------------------------
91 test();
92 //---------------------------------------------------------------------------------
93
94
95
96 function addThis()
97 {
98 statusList[UBound] = status;
99 actualvalue[UBound] = actual;
100 expectedvalue[UBound] = expect;
101 UBound++;
102 }
103
104
105 function test()
106 {
107 enterFunc ('test');
108 printBugNumber(BUGNUMBER);
109 printStatus (summary);
110
111 for (i = 0; i < UBound; i++)
112 {
113 reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
114 }
115
116 exitFunc ('test');
117 }
118
119
120 function getStatus(i)
121 {
122 return statprefix + statusList[i];
123 }