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