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//-------------------------------------------------------------------------------------------------
34var i = 0;
35var UBound = 0;
36var bug = 56868;
37var summary = 'Testing the internal [[Class]] property of native error constructors';
38var statprefix = 'Current constructor is: ';
39var status = ''; var statusList = [ ];
40var actual = ''; var actualvalue = [ ];
41var 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 */
47status = 'Error';
48actual = getJSClass(Error);
49expect = 'Function';
50addThis();
51
52status = 'EvalError';
53actual = getJSClass(EvalError);
54expect = 'Function';
55addThis();
56
57status = 'RangeError';
58actual = getJSClass(RangeError);
59expect = 'Function';
60addThis();
61
62status = 'ReferenceError';
63actual = getJSClass(ReferenceError);
64expect = 'Function';
65addThis();
66
67status = 'SyntaxError';
68actual = getJSClass(SyntaxError);
69expect = 'Function';
70addThis();
71
72status = 'TypeError';
73actual = getJSClass(TypeError);
74expect = 'Function';
75addThis();
76
77status = 'URIError';
78actual = getJSClass(URIError);
79expect = 'Function';
80addThis();
81
82
83
84//---------------------------------------------------------------------------------
85test();
86//---------------------------------------------------------------------------------
87
88
89
90function addThis()
91{
92  statusList[UBound] = status;
93  actualvalue[UBound] = actual;
94  expectedvalue[UBound] = expect;
95  UBound++;
96}
97
98
99function 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
114function getStatus(i)
115{
116  return statprefix + statusList[i];
117}
118