1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_5/extensions/arguments-property-access-in-function.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +/* 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/licenses/publicdomain/ 1.7 + * Contributor: 1.8 + * Jeff Walden <jwalden+code@mit.edu> 1.9 + */ 1.10 + 1.11 +//----------------------------------------------------------------------------- 1.12 +var BUGNUMBER = 721322; 1.13 +var summary = 1.14 + 'f.arguments must trigger an arguments object in non-strict mode functions'; 1.15 + 1.16 +print(BUGNUMBER + ": " + summary); 1.17 + 1.18 +/************** 1.19 + * BEGIN TEST * 1.20 + **************/ 1.21 + 1.22 +var obj = 1.23 + { 1.24 + test: function() 1.25 + { 1.26 + var args = obj.test.arguments; 1.27 + assertEq(args !== null, true); 1.28 + assertEq(args[0], 5); 1.29 + assertEq(args[1], undefined); 1.30 + assertEq(args.length, 2); 1.31 + } 1.32 + }; 1.33 +obj.test(5, undefined); 1.34 + 1.35 +var sobj = 1.36 + { 1.37 + test: function() 1.38 + { 1.39 + "use strict"; 1.40 + 1.41 + try 1.42 + { 1.43 + var args = sobj.test.arguments; 1.44 + throw new Error("access to arguments property of strict mode " + 1.45 + "function didn't throw"); 1.46 + } 1.47 + catch (e) 1.48 + { 1.49 + assertEq(e instanceof TypeError, true, 1.50 + "should have thrown TypeError, instead got: " + e); 1.51 + } 1.52 + } 1.53 + }; 1.54 +sobj.test(5, undefined); 1.55 + 1.56 +/******************************************************************************/ 1.57 + 1.58 +if (typeof reportCompare === "function") 1.59 + reportCompare(true, true); 1.60 + 1.61 +print("Tests complete");