js/src/tests/ecma_5/extensions/arguments-property-access-in-function.js

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

michael@0 1 /*
michael@0 2 * Any copyright is dedicated to the Public Domain.
michael@0 3 * http://creativecommons.org/licenses/publicdomain/
michael@0 4 * Contributor:
michael@0 5 * Jeff Walden <jwalden+code@mit.edu>
michael@0 6 */
michael@0 7
michael@0 8 //-----------------------------------------------------------------------------
michael@0 9 var BUGNUMBER = 721322;
michael@0 10 var summary =
michael@0 11 'f.arguments must trigger an arguments object in non-strict mode functions';
michael@0 12
michael@0 13 print(BUGNUMBER + ": " + summary);
michael@0 14
michael@0 15 /**************
michael@0 16 * BEGIN TEST *
michael@0 17 **************/
michael@0 18
michael@0 19 var obj =
michael@0 20 {
michael@0 21 test: function()
michael@0 22 {
michael@0 23 var args = obj.test.arguments;
michael@0 24 assertEq(args !== null, true);
michael@0 25 assertEq(args[0], 5);
michael@0 26 assertEq(args[1], undefined);
michael@0 27 assertEq(args.length, 2);
michael@0 28 }
michael@0 29 };
michael@0 30 obj.test(5, undefined);
michael@0 31
michael@0 32 var sobj =
michael@0 33 {
michael@0 34 test: function()
michael@0 35 {
michael@0 36 "use strict";
michael@0 37
michael@0 38 try
michael@0 39 {
michael@0 40 var args = sobj.test.arguments;
michael@0 41 throw new Error("access to arguments property of strict mode " +
michael@0 42 "function didn't throw");
michael@0 43 }
michael@0 44 catch (e)
michael@0 45 {
michael@0 46 assertEq(e instanceof TypeError, true,
michael@0 47 "should have thrown TypeError, instead got: " + e);
michael@0 48 }
michael@0 49 }
michael@0 50 };
michael@0 51 sobj.test(5, undefined);
michael@0 52
michael@0 53 /******************************************************************************/
michael@0 54
michael@0 55 if (typeof reportCompare === "function")
michael@0 56 reportCompare(true, true);
michael@0 57
michael@0 58 print("Tests complete");

mercurial