1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3
* The contents of this file are subject to the Netscape Public
4
* License Version 1.1 (the "License"); you may not use this file
5
* except in compliance with the License. You may obtain a copy of
6
* the License at http://www.mozilla.org/NPL/
8
* Software distributed under the License is distributed on an "AS
9
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
* implied. See the License for the specific language governing
11
* rights and limitations under the License.
13
* The Original Code is Mozilla Communicator client code, released March
16
* The Initial Developer of the Original Code is Netscape Communications
17
* Corporation. Portions created by Netscape are
18
* Copyright (C) 1998 Netscape Communications Corporation. All
21
* Contributor(s): Rob Ginda rginda@netscape.com
23
* SUMMARY: New properties fileName, lineNumber have been added to Error objects
24
* in SpiderMonkey. These are non-ECMA extensions and do not exist in Rhino.
26
* See http://bugzilla.mozilla.org/show_bug.cgi?id=50447
28
//-----------------------------------------------------------------------------
30
var summary = 'Test (non-ECMA) Error object properties fileName, lineNumber';
33
//-----------------------------------------------------------------------------
35
//-----------------------------------------------------------------------------
42
printStatus (summary);
54
function testRealError()
56
/* throw a real error, and see what it looks like */
57
enterFunc ("testRealError");
65
if (e.fileName.search (/-50447\.js$/i) == -1)
66
reportFailure ("expected fileName to end with '-50447.js'");
68
reportCompare (61, e.lineNumber,
69
"lineNumber property returned unexpected value.");
72
exitFunc ("testRealError");
78
/* generate an error with msg, file, and lineno properties */
81
var e = new InternalError ("msg", "file", 2);
82
reportCompare ("(new InternalError(\"msg\", \"file\", 2))",
84
"toSource() returned unexpected result.");
85
reportCompare ("file", e.fileName,
86
"fileName property returned unexpected value.");
87
reportCompare (2, e.lineNumber,
88
"lineNumber property returned unexpected value.");
96
/* generate an error with only msg property */
99
var e = new InternalError ("msg");
100
reportCompare ("(new InternalError(\"msg\", \"\"))",
102
"toSource() returned unexpected result.");
103
reportCompare ("", e.fileName,
104
"fileName property returned unexpected value.");
105
reportCompare (0, e.lineNumber,
106
"lineNumber property returned unexpected value.");
114
/* generate an error with only msg and lineNo properties */
117
var e = new InternalError ("msg");
119
reportCompare ("(new InternalError(\"msg\", \"\", 10))",
121
"toSource() returned unexpected result.");
122
reportCompare ("", e.fileName,
123
"fileName property returned unexpected value.");
124
reportCompare (10, e.lineNumber,
125
"lineNumber property returned unexpected value.");
133
/* generate an error with only msg and filename properties */
136
var e = new InternalError ("msg", "file");
137
reportCompare ("(new InternalError(\"msg\", \"file\"))",
139
"toSource() returned unexpected result.");
140
reportCompare ("file", e.fileName,
141
"fileName property returned unexpected value.");
142
reportCompare (0, e.lineNumber,
143
"lineNumber property returned unexpected value.");