Debian Codegraph @

rhino/testsrc/tests/ecma_3/Object/class-003.js

raw symbols SCIP
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 gTestfile = 'class-003.js';
23 var i = 0;
24 var UBound = 0;
25 var BUGNUMBER = 56868;
26 var summary = 'Testing the internal [[Class]] property of native error types';
27 var statprefix = 'Current object is: ';
28 var status = ''; var statusList = [ ];
29 var actual = ''; var actualvalue = [ ];
30 var expect= ''; var expectedvalue = [ ];
31
32 /*
33 * We set the expect variable each time only for readability.
34 * We expect 'Error' every time; see discussion above -
35 */
36 status = 'new Error()';
37 actual = getJSClass(new Error());
38 expect = 'Error';
39 addThis();
40
41 status = 'new EvalError()';
42 actual = getJSClass(new EvalError());
43 expect = 'Error';
44 addThis();
45
46 status = 'new RangeError()';
47 actual = getJSClass(new RangeError());
48 expect = 'Error';
49 addThis();
50
51 status = 'new ReferenceError()';
52 actual = getJSClass(new ReferenceError());
53 expect = 'Error';
54 addThis();
55
56 status = 'new SyntaxError()';
57 actual = getJSClass(new SyntaxError());
58 expect = 'Error';
59 addThis();
60
61 status = 'new TypeError()';
62 actual = getJSClass(new TypeError());
63 expect = 'Error';
64 addThis();
65
66 status = 'new URIError()';
67 actual = getJSClass(new URIError());
68 expect = 'Error';
69 addThis();
70
71
72
73 //---------------------------------------------------------------------------------
74 test();
75 //---------------------------------------------------------------------------------
76
77
78
79 function addThis()
80 {
81 statusList[UBound] = status;
82 actualvalue[UBound] = actual;
83 expectedvalue[UBound] = expect;
84 UBound++;
85 }
86
87
88 function test()
89 {
90 enterFunc ('test');
91 printBugNumber(BUGNUMBER);
92 printStatus (summary);
93
94 for (i = 0; i < UBound; i++)
95 {
96 reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
97 }
98
99 exitFunc ('test');
100 }
101
102
103 function getStatus(i)
104 {
105 return statprefix + statusList[i];
106 }