michael@0: // |reftest| skip-if(!xulRuntime.shell) -- needs evaluate() michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 577325; michael@0: var summary = 'Implement the ES5 algorithm for processing function statements'; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: var called, obj; michael@0: michael@0: function inFile1() { return "in file"; } michael@0: called = false; michael@0: obj = { set inFile1(v) { called = true; } }; michael@0: with (obj) michael@0: function inFile1() { return "in file in with"; }; michael@0: assertEq(inFile1(), "in file in with"); michael@0: assertEq("set" in Object.getOwnPropertyDescriptor(obj, "inFile1"), true); michael@0: assertEq(called, false); michael@0: michael@0: evaluate("function notInFile1() { return 'not in file'; }"); michael@0: called = false; michael@0: obj = { set notInFile1(v) { called = true; return "not in file 2"; } }; michael@0: with (obj) michael@0: function notInFile1() { return "not in file in with"; }; michael@0: assertEq(notInFile1(), "not in file in with"); michael@0: assertEq("set" in Object.getOwnPropertyDescriptor(obj, "notInFile1"), true); michael@0: assertEq(called, false); michael@0: michael@0: function inFile2() { return "in file 1"; } michael@0: called = false; michael@0: obj = michael@0: Object.defineProperty({}, "inFile2", michael@0: { value: 42, configurable: false, enumerable: false }); michael@0: with (obj) michael@0: function inFile2() { return "in file 2"; }; michael@0: assertEq(inFile2(), "in file 2"); michael@0: assertEq(obj.inFile2, 42); michael@0: michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("All tests passed!");