js/src/tests/ecma_3/Object/class-001.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:236d24e86ab0
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 i = 0;
16 var UBound = 0;
17 var BUGNUMBER = '(none)';
18 var summary = 'Testing the internal [[Class]] property of objects';
19 var statprefix = 'Current object is: ';
20 var status = ''; var statusList = [ ];
21 var actual = ''; var actualvalue = [ ];
22 var expect= ''; var expectedvalue = [ ];
23
24
25 status = 'the global object';
26 actual = getJSClass(this);
27 expect = GLOBAL;
28 if (expect == 'Window' && actual == 'XPCCrossOriginWrapper')
29 {
30 print('Skipping global object due to XPCCrossOriginWrapper. See bug 390946');
31 }
32 else
33 {
34 addThis();
35 }
36
37 status = 'new Object()';
38 actual = getJSClass(new Object());
39 expect = 'Object';
40 addThis();
41
42 status = 'new Function()';
43 actual = getJSClass(new Function());
44 expect = 'Function';
45 addThis();
46
47 status = 'new Array()';
48 actual = getJSClass(new Array());
49 expect = 'Array';
50 addThis();
51
52 status = 'new String()';
53 actual = getJSClass(new String());
54 expect = 'String';
55 addThis();
56
57 status = 'new Boolean()';
58 actual = getJSClass(new Boolean());
59 expect = 'Boolean';
60 addThis();
61
62 status = 'new Number()';
63 actual = getJSClass(new Number());
64 expect = 'Number';
65 addThis();
66
67 status = 'Math';
68 actual = getJSClass(Math); // can't use 'new' with the Math object (EMCA3, 15.8)
69 expect = 'Math';
70 addThis();
71
72 status = 'new Date()';
73 actual = getJSClass(new Date());
74 expect = 'Date';
75 addThis();
76
77 status = 'new RegExp()';
78 actual = getJSClass(new RegExp());
79 expect = 'RegExp';
80 addThis();
81
82 status = 'new Error()';
83 actual = getJSClass(new Error());
84 expect = 'Error';
85 addThis();
86
87
88
89 //---------------------------------------------------------------------------------
90 test();
91 //---------------------------------------------------------------------------------
92
93
94
95 function addThis()
96 {
97 statusList[UBound] = status;
98 actualvalue[UBound] = actual;
99 expectedvalue[UBound] = expect;
100 UBound++;
101 }
102
103
104 function test()
105 {
106 enterFunc ('test');
107 printBugNumber(BUGNUMBER);
108 printStatus (summary);
109
110 for (i = 0; i < UBound; i++)
111 {
112 reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
113 }
114
115 exitFunc ('test');
116 }
117
118
119 function getStatus(i)
120 {
121 return statprefix + statusList[i];
122 }

mercurial