|
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: 13 August 2001 |
|
8 * |
|
9 * SUMMARY: Invoking an undefined function should produce a ReferenceError |
|
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=95101 |
|
11 */ |
|
12 //----------------------------------------------------------------------------- |
|
13 var UBound = 0; |
|
14 var BUGNUMBER = 95101; |
|
15 var summary = 'Invoking an undefined function should produce a ReferenceError'; |
|
16 var msgERR_REF_YES = 'ReferenceError'; |
|
17 var msgERR_REF_NO = 'did NOT generate a ReferenceError'; |
|
18 var status = ''; |
|
19 var statusitems = []; |
|
20 var actual = ''; |
|
21 var actualvalues = []; |
|
22 var expect= ''; |
|
23 var expectedvalues = []; |
|
24 |
|
25 |
|
26 try |
|
27 { |
|
28 xxxyyyzzz(); |
|
29 } |
|
30 catch (e) |
|
31 { |
|
32 status = 'Section 1 of test'; |
|
33 actual = e instanceof ReferenceError; |
|
34 expect = true; |
|
35 addThis(); |
|
36 |
|
37 |
|
38 /* |
|
39 * This test is more literal, and may one day be invalid. |
|
40 * Searching for literal string "ReferenceError" in e.toString() |
|
41 */ |
|
42 status = 'Section 2 of test'; |
|
43 var match = e.toString().search(/ReferenceError/); |
|
44 actual = (match > -1); |
|
45 expect = true; |
|
46 addThis(); |
|
47 } |
|
48 |
|
49 |
|
50 |
|
51 //----------------------------------------------------------------------------- |
|
52 test(); |
|
53 //----------------------------------------------------------------------------- |
|
54 |
|
55 |
|
56 function addThis() |
|
57 { |
|
58 statusitems[UBound] = status; |
|
59 actualvalues[UBound] = isReferenceError(actual); |
|
60 expectedvalues[UBound] = isReferenceError(expect); |
|
61 UBound++; |
|
62 } |
|
63 |
|
64 |
|
65 function test() |
|
66 { |
|
67 enterFunc ('test'); |
|
68 printBugNumber(BUGNUMBER); |
|
69 printStatus (summary); |
|
70 |
|
71 for (var i = 0; i < UBound; i++) |
|
72 { |
|
73 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
|
74 } |
|
75 |
|
76 exitFunc ('test'); |
|
77 } |
|
78 |
|
79 |
|
80 // converts a Boolean result into a textual result - |
|
81 function isReferenceError(bResult) |
|
82 { |
|
83 return bResult? msgERR_REF_YES : msgERR_REF_NO; |
|
84 } |