~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/JavaScriptCore/tests/mozilla/js1_5/Exceptions/regress-50447.js

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 
2
*
 
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/
 
7
*
 
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.
 
12
*
 
13
* The Original Code is Mozilla Communicator client code, released March
 
14
* 31, 1998.
 
15
*
 
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
 
19
* Rights Reserved.
 
20
*
 
21
* Contributor(s): Rob Ginda rginda@netscape.com
 
22
*
 
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.
 
25
*
 
26
* See http://bugzilla.mozilla.org/show_bug.cgi?id=50447
 
27
*/
 
28
//-----------------------------------------------------------------------------
 
29
var bug = 50447;
 
30
var summary = 'Test (non-ECMA) Error object properties fileName, lineNumber';
 
31
 
 
32
 
 
33
//-----------------------------------------------------------------------------
 
34
test();
 
35
//-----------------------------------------------------------------------------
 
36
 
 
37
 
 
38
function test()
 
39
{
 
40
  enterFunc ('test');
 
41
  printBugNumber (bug);
 
42
  printStatus (summary);
 
43
  
 
44
  testRealError();
 
45
  test1();
 
46
  test2();
 
47
  test3();
 
48
  test4();
 
49
 
 
50
  exitFunc('test');
 
51
}
 
52
 
 
53
 
 
54
function testRealError()
 
55
{
 
56
    /* throw a real error, and see what it looks like */
 
57
    enterFunc ("testRealError");
 
58
    
 
59
    try 
 
60
    {
 
61
        blabla;
 
62
    }
 
63
    catch (e)
 
64
    {
 
65
        if (e.fileName.search (/-50447\.js$/i) == -1)
 
66
            reportFailure ("expected fileName to end with '-50447.js'");
 
67
 
 
68
        reportCompare (61, e.lineNumber,
 
69
                       "lineNumber property returned unexpected value.");
 
70
    }
 
71
    
 
72
    exitFunc ("testRealError");
 
73
}    
 
74
 
 
75
 
 
76
function test1()
 
77
{
 
78
    /* generate an error with msg, file, and lineno properties */
 
79
    enterFunc ("test1");
 
80
 
 
81
    var e = new InternalError ("msg", "file", 2);
 
82
    reportCompare ("(new InternalError(\"msg\", \"file\", 2))",
 
83
                   e.toSource(),
 
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.");
 
89
    
 
90
    exitFunc ("test1");
 
91
}
 
92
 
 
93
 
 
94
function test2()
 
95
{
 
96
    /* generate an error with only msg property */
 
97
    enterFunc ("test2");
 
98
 
 
99
    var e = new InternalError ("msg");
 
100
    reportCompare ("(new InternalError(\"msg\", \"\"))",
 
101
                   e.toSource(),
 
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.");
 
107
    
 
108
    exitFunc ("test2");
 
109
}
 
110
 
 
111
 
 
112
function test3()
 
113
{
 
114
    /* generate an error with only msg and lineNo properties */
 
115
    enterFunc ("test3");
 
116
 
 
117
    var e = new InternalError ("msg");
 
118
    e.lineNumber = 10;
 
119
    reportCompare ("(new InternalError(\"msg\", \"\", 10))",
 
120
                   e.toSource(),
 
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.");
 
126
    
 
127
    exitFunc ("test3");
 
128
}
 
129
 
 
130
 
 
131
function test4()
 
132
{
 
133
    /* generate an error with only msg and filename properties */
 
134
    enterFunc ("test4");
 
135
 
 
136
    var e = new InternalError ("msg", "file");
 
137
    reportCompare ("(new InternalError(\"msg\", \"file\"))",
 
138
                   e.toSource(),
 
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.");
 
144
    
 
145
    exitFunc ("test4");
 
146
}