1 /* 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 (at) 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 //----------------------------------------------------------------------------- 26 var UBound = 0; 27 var bug = 95101; 28 var summary = 'Invoking an undefined function should produce a ReferenceError'; 29 var msgERR_REF_YES = 'ReferenceError'; 30 var msgERR_REF_NO = 'did NOT generate a ReferenceError'; 31 var status = ''; 32 var statusitems = []; 33 var actual = ''; 34 var actualvalues = []; 35 var expect= ''; 36 var expectedvalues = []; 37 38 39 try 40 { 41 xxxyyyzzz(); 42 } 43 catch (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 //----------------------------------------------------------------------------- 65 test(); 66 //----------------------------------------------------------------------------- 67 68 69 function addThis() 70 { 71 statusitems[UBound] = status; 72 actualvalues[UBound] = isReferenceError(actual); 73 expectedvalues[UBound] = isReferenceError(expect); 74 UBound++; 75 } 76 77 78 function 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 - 94 function isReferenceError(bResult) 95 { 96 return bResult? msgERR_REF_YES : msgERR_REF_NO; 97 } 98