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: calling obj.eval(str) 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: * "Backward compatibility: support calling obj.eval(str), which evaluates michael@0: * str using obj as the scope chain and variable object." michael@0: */ michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 68498; michael@0: var summary = 'Testing calling obj.eval(str)'; 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) {self.eval(s); return y;} michael@0: michael@0: michael@0: // Set the actual-results array - michael@0: actual[0] = f('var y = 43'); michael@0: actual[1] = 'y' in self && y; michael@0: actual[2] = delete y; michael@0: actual[3] = 'y' in self; michael@0: michael@0: // Set the expected-results array - michael@0: expect[0] = 43; michael@0: expect[1] = 43; michael@0: expect[2] = true; michael@0: expect[3] = 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: }