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: var gTestfile = 'assign-to-callee-name.js'; michael@0: var BUGNUMBER = 610350; michael@0: var summary = michael@0: "Assigning to a function expression's name within that function should " + michael@0: "throw a TypeError in strict mode code"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: var f = function assignSelfStrict() { "use strict"; assignSelfStrict = 12; }; michael@0: michael@0: try michael@0: { michael@0: var r = f(); michael@0: throw new Error("should have thrown a TypeError, returned " + r); michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof TypeError, true, michael@0: "didn't throw a TypeError: " + e); michael@0: } michael@0: michael@0: var assignSelf = 42; michael@0: var f2 = function assignSelf() { assignSelf = 12; }; michael@0: michael@0: f2(); // shouldn't throw, does nothing michael@0: assertEq(assignSelf, 42); 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!");