]>
Commit | Line | Data |
---|---|---|
b37bf2e1 A |
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 [[Class]] property of native error constructors. | |
23 | * See ECMA-262 Edition 3, Section 8.6.2 for the [[Class]] property. | |
24 | * | |
25 | * See ECMA-262 Edition 3, Section 15.11.6 for the native error types. | |
26 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=56868 | |
27 | * | |
28 | * Same as class-003.js - but testing the constructors here, not object instances. | |
29 | * Therefore we expect the [[Class]] property to equal 'Function' in each case. | |
30 | * | |
31 | * The getJSClass() function we use is in a utility file, e.g. "shell.js" | |
32 | */ | |
33 | //------------------------------------------------------------------------------------------------- | |
34 | var i = 0; | |
35 | var UBound = 0; | |
36 | var bug = 56868; | |
37 | var summary = 'Testing the internal [[Class]] property of native error constructors'; | |
38 | var statprefix = 'Current constructor is: '; | |
39 | var status = ''; var statusList = [ ]; | |
40 | var actual = ''; var actualvalue = [ ]; | |
41 | var expect= ''; var expectedvalue = [ ]; | |
42 | ||
43 | /* | |
44 | * We set the expect variable each time only for readability. | |
45 | * We expect 'Function' every time; see discussion above - | |
46 | */ | |
47 | status = 'Error'; | |
48 | actual = getJSClass(Error); | |
49 | expect = 'Function'; | |
50 | addThis(); | |
51 | ||
52 | status = 'EvalError'; | |
53 | actual = getJSClass(EvalError); | |
54 | expect = 'Function'; | |
55 | addThis(); | |
56 | ||
57 | status = 'RangeError'; | |
58 | actual = getJSClass(RangeError); | |
59 | expect = 'Function'; | |
60 | addThis(); | |
61 | ||
62 | status = 'ReferenceError'; | |
63 | actual = getJSClass(ReferenceError); | |
64 | expect = 'Function'; | |
65 | addThis(); | |
66 | ||
67 | status = 'SyntaxError'; | |
68 | actual = getJSClass(SyntaxError); | |
69 | expect = 'Function'; | |
70 | addThis(); | |
71 | ||
72 | status = 'TypeError'; | |
73 | actual = getJSClass(TypeError); | |
74 | expect = 'Function'; | |
75 | addThis(); | |
76 | ||
77 | status = 'URIError'; | |
78 | actual = getJSClass(URIError); | |
79 | expect = 'Function'; | |
80 | addThis(); | |
81 | ||
82 | ||
83 | ||
84 | //--------------------------------------------------------------------------------- | |
85 | test(); | |
86 | //--------------------------------------------------------------------------------- | |
87 | ||
88 | ||
89 | ||
90 | function addThis() | |
91 | { | |
92 | statusList[UBound] = status; | |
93 | actualvalue[UBound] = actual; | |
94 | expectedvalue[UBound] = expect; | |
95 | UBound++; | |
96 | } | |
97 | ||
98 | ||
99 | function test() | |
100 | { | |
101 | enterFunc ('test'); | |
102 | printBugNumber (bug); | |
103 | printStatus (summary); | |
104 | ||
105 | for (i = 0; i < UBound; i++) | |
106 | { | |
107 | reportCompare(expectedvalue[i], actualvalue[i], getStatus(i)); | |
108 | } | |
109 | ||
110 | exitFunc ('test'); | |
111 | } | |
112 | ||
113 | ||
114 | function getStatus(i) | |
115 | { | |
116 | return statprefix + statusList[i]; | |
117 | } |