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