michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Date: 2001-07-10 michael@0: * michael@0: * SUMMARY: Invoking try...catch through Function.call michael@0: * See http://bugzilla.mozilla.org/show_bug.cgi?id=49286 michael@0: * michael@0: * 1) Define a function with a try...catch block in it michael@0: * 2) Invoke the function via the call method of Function michael@0: * 3) Pass bad syntax to the try...catch block michael@0: * 4) We should catch the error! michael@0: */ michael@0: //----------------------------------------------------------------------------- michael@0: var UBound = 0; michael@0: var BUGNUMBER = 49286; michael@0: var summary = 'Invoking try...catch through Function.call'; michael@0: var cnErrorCaught = 'Error caught'; michael@0: var cnErrorNotCaught = 'Error NOT caught'; michael@0: var cnGoodSyntax = '1==2'; michael@0: var cnBadSyntax = '1=2'; michael@0: var status = ''; michael@0: var statusitems = []; michael@0: var actual = ''; michael@0: var actualvalues = []; michael@0: var expect= ''; michael@0: var expectedvalues = []; michael@0: michael@0: michael@0: var obj = new testObject(); michael@0: michael@0: status = 'Section A of test: direct call of f'; michael@0: actual = f.call(obj); michael@0: expect = cnErrorCaught; michael@0: addThis(); michael@0: michael@0: status = 'Section B of test: indirect call of f'; michael@0: actual = g.call(obj); michael@0: expect = cnErrorCaught; michael@0: addThis(); michael@0: michael@0: michael@0: michael@0: //----------------------------------------- michael@0: test(); michael@0: //----------------------------------------- michael@0: michael@0: michael@0: function test() michael@0: { michael@0: enterFunc ('test'); michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: for (var i=0; i