|
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: 01 Feb 2002 |
|
9 * SUMMARY: Testing Error.length |
|
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=123002 |
|
11 * |
|
12 * NOTE: Error.length should equal the length of FormalParameterList of the |
|
13 * Error constructor. This is currently 1 in Rhino, 3 in SpiderMonkey. |
|
14 * |
|
15 * The difference is due to http://bugzilla.mozilla.org/show_bug.cgi?id=50447. |
|
16 * As a result of that bug, SpiderMonkey has extended ECMA to allow two new |
|
17 * parameters to Error constructors: |
|
18 * |
|
19 * Rhino: new Error (message) |
|
20 * SpiderMonkey: new Error (message, fileName, lineNumber) |
|
21 * |
|
22 * NOTE: since we have hard-coded the length expectations, this testcase will |
|
23 * have to be changed if the Error FormalParameterList is ever changed again. |
|
24 * |
|
25 * To do this, just change the two LENGTH constants below - |
|
26 */ |
|
27 //----------------------------------------------------------------------------- |
|
28 var UBound = 0; |
|
29 var BUGNUMBER = 123002; |
|
30 var summary = 'Testing Error.length'; |
|
31 var QUOTE = '"'; |
|
32 var status = ''; |
|
33 var statusitems = []; |
|
34 var actual = ''; |
|
35 var actualvalues = []; |
|
36 var expect= ''; |
|
37 var expectedvalues = []; |
|
38 |
|
39 |
|
40 var LENGTH_EXPECTED = 1; |
|
41 |
|
42 /* |
|
43 * The various NativeError objects; see ECMA-262 Edition 3, Section 15.11.6 |
|
44 */ |
|
45 var errObjects = [new Error(), new EvalError(), new RangeError(), |
|
46 new ReferenceError(), new SyntaxError(), new TypeError(), new URIError()]; |
|
47 |
|
48 |
|
49 for (var i in errObjects) |
|
50 { |
|
51 var err = errObjects[i]; |
|
52 status = inSection(quoteThis(err.name)); |
|
53 actual = Error.length; |
|
54 expect = LENGTH_EXPECTED; |
|
55 addThis(); |
|
56 } |
|
57 |
|
58 |
|
59 |
|
60 //----------------------------------------------------------------------------- |
|
61 test(); |
|
62 //----------------------------------------------------------------------------- |
|
63 |
|
64 |
|
65 |
|
66 function addThis() |
|
67 { |
|
68 statusitems[UBound] = status; |
|
69 actualvalues[UBound] = actual; |
|
70 expectedvalues[UBound] = expect; |
|
71 UBound++; |
|
72 } |
|
73 |
|
74 |
|
75 function test() |
|
76 { |
|
77 enterFunc('test'); |
|
78 printBugNumber(BUGNUMBER); |
|
79 printStatus(summary); |
|
80 |
|
81 for (var i=0; i<UBound; i++) |
|
82 { |
|
83 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
|
84 } |
|
85 |
|
86 exitFunc ('test'); |
|
87 } |
|
88 |
|
89 |
|
90 function quoteThis(text) |
|
91 { |
|
92 return QUOTE + text + QUOTE; |
|
93 } |