1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/Exceptions/regress-95101.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,84 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * Date: 13 August 2001 1.11 + * 1.12 + * SUMMARY: Invoking an undefined function should produce a ReferenceError 1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=95101 1.14 + */ 1.15 +//----------------------------------------------------------------------------- 1.16 +var UBound = 0; 1.17 +var BUGNUMBER = 95101; 1.18 +var summary = 'Invoking an undefined function should produce a ReferenceError'; 1.19 +var msgERR_REF_YES = 'ReferenceError'; 1.20 +var msgERR_REF_NO = 'did NOT generate a ReferenceError'; 1.21 +var status = ''; 1.22 +var statusitems = []; 1.23 +var actual = ''; 1.24 +var actualvalues = []; 1.25 +var expect= ''; 1.26 +var expectedvalues = []; 1.27 + 1.28 + 1.29 +try 1.30 +{ 1.31 + xxxyyyzzz(); 1.32 +} 1.33 +catch (e) 1.34 +{ 1.35 + status = 'Section 1 of test'; 1.36 + actual = e instanceof ReferenceError; 1.37 + expect = true; 1.38 + addThis(); 1.39 + 1.40 + 1.41 + /* 1.42 + * This test is more literal, and may one day be invalid. 1.43 + * Searching for literal string "ReferenceError" in e.toString() 1.44 + */ 1.45 + status = 'Section 2 of test'; 1.46 + var match = e.toString().search(/ReferenceError/); 1.47 + actual = (match > -1); 1.48 + expect = true; 1.49 + addThis(); 1.50 +} 1.51 + 1.52 + 1.53 + 1.54 +//----------------------------------------------------------------------------- 1.55 +test(); 1.56 +//----------------------------------------------------------------------------- 1.57 + 1.58 + 1.59 +function addThis() 1.60 +{ 1.61 + statusitems[UBound] = status; 1.62 + actualvalues[UBound] = isReferenceError(actual); 1.63 + expectedvalues[UBound] = isReferenceError(expect); 1.64 + UBound++; 1.65 +} 1.66 + 1.67 + 1.68 +function test() 1.69 +{ 1.70 + enterFunc ('test'); 1.71 + printBugNumber(BUGNUMBER); 1.72 + printStatus (summary); 1.73 + 1.74 + for (var i = 0; i < UBound; i++) 1.75 + { 1.76 + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 1.77 + } 1.78 + 1.79 + exitFunc ('test'); 1.80 +} 1.81 + 1.82 + 1.83 +// converts a Boolean result into a textual result - 1.84 +function isReferenceError(bResult) 1.85 +{ 1.86 + return bResult? msgERR_REF_YES : msgERR_REF_NO; 1.87 +}