Debian Codegraph @

rhino/testsrc/tests/ecma_3/Object/class-004.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 [[Class]] property of native error constructors.
10 * See ECMA-262 Edition 3, Section 8.6.2 for the [[Class]] property.
11 *
12 * See ECMA-262 Edition 3, Section 15.11.6 for the native error types.
13 * See http://bugzilla.mozilla.org/show_bug.cgi?id=56868
14 *
15 * Same as class-003.js - but testing the constructors here, not
16 * object instances. Therefore we expect the [[Class]] property to
17 * equal 'Function' in each case.
18 *
19 * The getJSClass() function we use is in a utility file, e.g. "shell.js"
20 */
21 //-----------------------------------------------------------------------------
22 var gTestfile = 'class-004.js';
23 var i = 0;
24 var UBound = 0;
25 var BUGNUMBER = 56868;
26 var summary = 'Testing the internal [[Class]] property of native error constructors';
27 var statprefix = 'Current constructor 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 'Function' every time; see discussion above -
35 */
36 status = 'Error';
37 actual = getJSClass(Error);
38 expect = 'Function';
39 addThis();
40
41 status = 'EvalError';
42 actual = getJSClass(EvalError);
43 expect = 'Function';
44 addThis();
45
46 status = 'RangeError';
47 actual = getJSClass(RangeError);
48 expect = 'Function';
49 addThis();
50
51 status = 'ReferenceError';
52 actual = getJSClass(ReferenceError);
53 expect = 'Function';
54 addThis();
55
56 status = 'SyntaxError';
57 actual = getJSClass(SyntaxError);
58 expect = 'Function';
59 addThis();
60
61 status = 'TypeError';
62 actual = getJSClass(TypeError);
63 expect = 'Function';
64 addThis();
65
66 status = 'URIError';
67 actual = getJSClass(URIError);
68 expect = 'Function';
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 }