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