]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_3/Object/class-002.js
JavaScriptCore-461.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma_3 / Object / class-002.js
1 /*
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 [[Class]] property of native constructors.
23 * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property.
24 *
25 * Same as class-001.js - but testing the constructors here, not object instances.
26 * Therefore we expect the [[Class]] property to equal 'Function' in each case.
27 *
28 * The getJSClass() function we use is in a utility file, e.g. "shell.js"
29 */
30 //-------------------------------------------------------------------------------------------------
31 var i = 0;
32 var UBound = 0;
33 var bug = '(none)';
34 var summary = 'Testing the internal [[Class]] property of native constructors';
35 var statprefix = 'Current constructor is: ';
36 var status = ''; var statusList = [ ];
37 var actual = ''; var actualvalue = [ ];
38 var expect= ''; var expectedvalue = [ ];
39
40 /*
41 * We set the expect variable each time only for readability.
42 * We expect 'Function' every time; see discussion above -
43 */
44 status = 'Object';
45 actual = getJSClass(Object);
46 expect = 'Function';
47 addThis();
48
49 status = 'Function';
50 actual = getJSClass(Function);
51 expect = 'Function';
52 addThis();
53
54 status = 'Array';
55 actual = getJSClass(Array);
56 expect = 'Function';
57 addThis();
58
59 status = 'String';
60 actual = getJSClass(String);
61 expect = 'Function';
62 addThis();
63
64 status = 'Boolean';
65 actual = getJSClass(Boolean);
66 expect = 'Function';
67 addThis();
68
69 status = 'Number';
70 actual = getJSClass(Number);
71 expect = 'Function';
72 addThis();
73
74 status = 'Date';
75 actual = getJSClass(Date);
76 expect = 'Function';
77 addThis();
78
79 status = 'RegExp';
80 actual = getJSClass(RegExp);
81 expect = 'Function';
82 addThis();
83
84 status = 'Error';
85 actual = getJSClass(Error);
86 expect = 'Function';
87 addThis();
88
89
90
91 //---------------------------------------------------------------------------------
92 test();
93 //---------------------------------------------------------------------------------
94
95
96
97 function addThis()
98 {
99 statusList[UBound] = status;
100 actualvalue[UBound] = actual;
101 expectedvalue[UBound] = expect;
102 UBound++;
103 }
104
105
106 function test()
107 {
108 enterFunc ('test');
109 printBugNumber (bug);
110 printStatus (summary);
111
112 for (i = 0; i < UBound; i++)
113 {
114 reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
115 }
116
117 exitFunc ('test');
118 }
119
120
121 function getStatus(i)
122 {
123 return statprefix + statusList[i];
124 }