Debian Codegraph @

rhino/testsrc/tests/ecma_3/Exceptions/15.11.7.6-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 *
8 * Date: 14 April 2003
9 * SUMMARY: Prototype of predefined error objects should be ReadOnly
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=201989
11 *
12 */
13 //-----------------------------------------------------------------------------
14 var gTestfile = '15.11.7.6-003.js';
15 var UBound = 0;
16 var BUGNUMBER = 201989;
17 var summary = 'Prototype of predefined error objects should be ReadOnly';
18 var status = '';
19 var statusitems = [];
20 var actual = '';
21 var actualvalues = [];
22 var expect= '';
23 var expectedvalues = [];
24
25
26 /*
27 * Tests that |F.prototype| is ReadOnly
28 */
29 function testReadOnly(F)
30 {
31 var e;
32 var orig = F.prototype;
33 try
34 {
35 F.prototype = new Object();
36 }
37 catch (e)
38 {
39 }
40 return F.prototype === orig;
41 }
42
43
44 var list = [
45 "Error",
46 "ConversionError",
47 "EvalError",
48 "RangeError",
49 "ReferenceError",
50 "SyntaxError",
51 "TypeError",
52 "URIError"
53 ];
54
55
56 for (i in list)
57 {
58 var F = this[list[i]];
59
60 // Test for |F|; e.g. Rhino defines |ConversionError| while SM does not.
61 if (F)
62 {
63 status = 'Testing ReadOnly attribute of |' + list[i] + '.prototype|';
64 actual = testReadOnly(F);
65 expect = true;
66 addThis();
67 }
68 }
69
70
71
72 //-----------------------------------------------------------------------------
73 test();
74 //-----------------------------------------------------------------------------
75
76
77
78 function addThis()
79 {
80 statusitems[UBound] = status;
81 actualvalues[UBound] = actual;
82 expectedvalues[UBound] = expect;
83 UBound++;
84 }
85
86
87 function test()
88 {
89 enterFunc('test');
90 printBugNumber(BUGNUMBER);
91 printStatus(summary);
92
93 for (var i=0; i<UBound; i++)
94 {
95 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
96 }
97
98 exitFunc ('test');
99 }