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: 15 Feb 2001 michael@0: * michael@0: * SUMMARY: create a Deletable local variable using eval michael@0: * michael@0: * See http://bugzilla.mozilla.org/show_bug.cgi?id=68498 michael@0: * See http://bugzilla.mozilla.org/showattachment.cgi?attach_id=25251 michael@0: * michael@0: * Brendan: michael@0: * michael@0: * "Demonstrate the creation of a Deletable local variable using eval" michael@0: */ michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 68498; michael@0: var summary = 'Creating a Deletable local variable using eval'; michael@0: var statprefix = '; currently at expect['; michael@0: var statsuffix = '] within test -'; michael@0: var actual = [ ]; michael@0: var expect = [ ]; michael@0: michael@0: michael@0: // Capture a reference to the global object - michael@0: var self = this; michael@0: michael@0: // This function is the heart of the test - michael@0: function f(s) {eval(s); actual[0]=y; return delete y;} michael@0: michael@0: michael@0: // Set the actual-results array. The next line will set actual[0] and actual[1] in one shot michael@0: actual[1] = f('var y = 42'); michael@0: actual[2] = 'y' in self && y; michael@0: michael@0: // Set the expected-results array - michael@0: expect[0] = 42; michael@0: expect[1] = true; michael@0: expect[2] = false; 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 in expect) michael@0: { michael@0: reportCompare(expect[i], actual[i], getStatus(i)); michael@0: } michael@0: michael@0: exitFunc ('test'); michael@0: } michael@0: michael@0: michael@0: function getStatus(i) michael@0: { michael@0: return (summary + statprefix + i + statsuffix); michael@0: }