blob: 6572995ff776e12144770ccd3d59c6327605acb2 [file] [log] [blame]
darincd553de2003-10-13 02:05:37 +00001/*
2* The contents of this file are subject to the Netscape Public
3* License Version 1.1 (the "License"); you may not use this file
4* except in compliance with the License. You may obtain a copy of
5* the License at http://www.mozilla.org/NPL/
6*
7* Software distributed under the License is distributed on an "AS IS"
8* basis, WITHOUT WARRANTY OF ANY KIND, either expressed
9* or implied. See the License for the specific language governing
10* rights and limitations under the License.
11*
12* The Original Code is mozilla.org code.
13*
14* The Initial Developer of the Original Code is Netscape
15* Communications Corporation. Portions created by Netscape are
16* Copyright (C) 1998 Netscape Communications Corporation. All
17* Rights Reserved.
18*
19* Contributor(s): pschwartau@netscape.com
20* Date: 14 Mar 2001
21*
22* SUMMARY: Testing the internal [[Class]] property of objects
23* See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2
24*
25* The getJSClass() function we use is in a utility file, e.g. "shell.js".
26*/
27//-------------------------------------------------------------------------------------------------
28var i = 0;
29var UBound = 0;
30var bug = '(none)';
31var summary = 'Testing the internal [[Class]] property of objects';
32var statprefix = 'Current object is: ';
33var status = ''; var statusList = [ ];
34var actual = ''; var actualvalue = [ ];
35var expect= ''; var expectedvalue = [ ];
36
37
38status = 'the global object';
39actual = getJSClass(this);
40expect = 'global';
41addThis();
42
43status = 'new Object()';
44actual = getJSClass(new Object());
45expect = 'Object';
46addThis();
47
48status = 'new Function()';
49actual = getJSClass(new Function());
50expect = 'Function';
51addThis();
52
53status = 'new Array()';
54actual = getJSClass(new Array());
55expect = 'Array';
56addThis();
57
58status = 'new String()';
59actual = getJSClass(new String());
60expect = 'String';
61addThis();
62
63status = 'new Boolean()';
64actual = getJSClass(new Boolean());
65expect = 'Boolean';
66addThis();
67
68status = 'new Number()';
69actual = getJSClass(new Number());
70expect = 'Number';
71addThis();
72
73status = 'Math';
74actual = getJSClass(Math); // can't use 'new' with the Math object (EMCA3, 15.8)
75expect = 'Math';
76addThis();
77
78status = 'new Date()';
79actual = getJSClass(new Date());
80expect = 'Date';
81addThis();
82
83status = 'new RegExp()';
84actual = getJSClass(new RegExp());
85expect = 'RegExp';
86addThis();
87
88status = 'new Error()';
89actual = getJSClass(new Error());
90expect = 'Error';
91addThis();
92
93
94
95//---------------------------------------------------------------------------------
96test();
97//---------------------------------------------------------------------------------
98
99
100
101function addThis()
102{
103 statusList[UBound] = status;
104 actualvalue[UBound] = actual;
105 expectedvalue[UBound] = expect;
106 UBound++;
107}
108
109
110function test()
111{
112 enterFunc ('test');
113 printBugNumber (bug);
114 printStatus (summary);
115
116 for (i = 0; i < UBound; i++)
117 {
118 reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
119 }
120
121 exitFunc ('test');
122}
123
124
125function getStatus(i)
126{
127 return statprefix + statusList[i];
128}