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