blob: 59b5209788b2b93f9d86731e574ea45aaea0a125 [file] [log] [blame]
darincd553de2003-10-13 02:05:37 +00001/*
2* The contents of this file are subject to the Netscape Public
3* License Version 1.1 (the "License"); you may not use this file
4* except in compliance with the License. You may obtain a copy of
5* the License at http://www.mozilla.org/NPL/
6*
7* Software distributed under the License is distributed on an "AS
8* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9* implied. See the License for the specific language governing
10* rights and limitations under the License.
11*
12* The Original Code is mozilla.org code.
13*
14* The Initial Developer of the Original Code is Netscape
15* Communications Corporation. Portions created by Netscape are
16* Copyright (C) 1998 Netscape Communications Corporation.
17* All Rights Reserved.
18*
19* Contributor(s): pschwartau@netscape.com
20* Date: 13 August 2001
21*
22* SUMMARY: Invoking an undefined function should produce a ReferenceError
23* See http://bugzilla.mozilla.org/show_bug.cgi?id=95101
24*/
25//-----------------------------------------------------------------------------
26var UBound = 0;
27var bug = 95101;
28var summary = 'Invoking an undefined function should produce a ReferenceError';
29var msgERR_REF_YES = 'ReferenceError';
30var msgERR_REF_NO = 'did NOT generate a ReferenceError';
31var status = '';
32var statusitems = [];
33var actual = '';
34var actualvalues = [];
35var expect= '';
36var expectedvalues = [];
37
38
39try
40{
41 xxxyyyzzz();
42}
43catch (e)
44{
45 status = 'Section 1 of test';
46 actual = e instanceof ReferenceError;
47 expect = true;
48 addThis();
49
50
51 /*
52 * This test is more literal, and may one day be invalid.
53 * Searching for literal string "ReferenceError" in e.toString()
54 */
55 status = 'Section 2 of test';
56 var match = e.toString().search(/ReferenceError/);
57 actual = (match > -1);
58 expect = true;
59 addThis();
60}
61
62
63
64//-----------------------------------------------------------------------------
65test();
66//-----------------------------------------------------------------------------
67
68
69function addThis()
70{
71 statusitems[UBound] = status;
72 actualvalues[UBound] = isReferenceError(actual);
73 expectedvalues[UBound] = isReferenceError(expect);
74 UBound++;
75}
76
77
78function test()
79{
80 enterFunc ('test');
81 printBugNumber (bug);
82 printStatus (summary);
83
84 for (var i = 0; i < UBound; i++)
85 {
86 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
87 }
88
89 exitFunc ('test');
90}
91
92
93// converts a Boolean result into a textual result -
94function isReferenceError(bResult)
95{
96 return bResult? msgERR_REF_YES : msgERR_REF_NO;
97}