1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_5/strict/assign-to-callee-name.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,42 @@ 1.4 +/* 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/licenses/publicdomain/ 1.7 + */ 1.8 + 1.9 +var gTestfile = 'assign-to-callee-name.js'; 1.10 +var BUGNUMBER = 610350; 1.11 +var summary = 1.12 + "Assigning to a function expression's name within that function should " + 1.13 + "throw a TypeError in strict mode code"; 1.14 + 1.15 +print(BUGNUMBER + ": " + summary); 1.16 + 1.17 +/************** 1.18 + * BEGIN TEST * 1.19 + **************/ 1.20 + 1.21 +var f = function assignSelfStrict() { "use strict"; assignSelfStrict = 12; }; 1.22 + 1.23 +try 1.24 +{ 1.25 + var r = f(); 1.26 + throw new Error("should have thrown a TypeError, returned " + r); 1.27 +} 1.28 +catch (e) 1.29 +{ 1.30 + assertEq(e instanceof TypeError, true, 1.31 + "didn't throw a TypeError: " + e); 1.32 +} 1.33 + 1.34 +var assignSelf = 42; 1.35 +var f2 = function assignSelf() { assignSelf = 12; }; 1.36 + 1.37 +f2(); // shouldn't throw, does nothing 1.38 +assertEq(assignSelf, 42); 1.39 + 1.40 +/******************************************************************************/ 1.41 + 1.42 +if (typeof reportCompare === "function") 1.43 + reportCompare(true, true); 1.44 + 1.45 +print("All tests passed!");