js/src/tests/ecma_5/Function/redefine-arguments-length.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_5/Function/redefine-arguments-length.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,65 @@
     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 = 'redefine-arguments-length.js';
    1.10 +//-----------------------------------------------------------------------------
    1.11 +var BUGNUMBER = 539766;
    1.12 +var summary =
    1.13 +  "Object.defineProperty sets arguments.length without setting the " +
    1.14 +  "length-overridden bit";
    1.15 +
    1.16 +print(BUGNUMBER + ": " + summary);
    1.17 +
    1.18 +/**************
    1.19 + * BEGIN TEST *
    1.20 + **************/
    1.21 +
    1.22 +function test_JSOP_ARGCNT()
    1.23 +{
    1.24 +  var length = "length";
    1.25 +  Object.defineProperty(arguments, length, { value: 17 });
    1.26 +  assertEq(arguments.length, 17);
    1.27 +  assertEq(arguments[length], 17);
    1.28 +}
    1.29 +test_JSOP_ARGCNT();
    1.30 +
    1.31 +function test_js_fun_apply()
    1.32 +{
    1.33 +  var length = "length";
    1.34 +  Object.defineProperty(arguments, length, { value: 17 });
    1.35 +
    1.36 +  function fun()
    1.37 +  {
    1.38 +    assertEq(arguments.length, 17);
    1.39 +    assertEq(arguments[length], 17);
    1.40 +    assertEq(arguments[0], "foo");
    1.41 +    for (var i = 1; i < 17; i++)
    1.42 +      assertEq(arguments[i], undefined);
    1.43 +  }
    1.44 +  fun.apply(null, arguments);
    1.45 +}
    1.46 +test_js_fun_apply("foo");
    1.47 +
    1.48 +function test_array_toString_sub_1()
    1.49 +{
    1.50 +  Object.defineProperty(arguments, "length", { value: 1 });
    1.51 +  arguments.join = [].join;
    1.52 +  assertEq([].toString.call(arguments), "1");
    1.53 +}
    1.54 +test_array_toString_sub_1(1, 2);
    1.55 +
    1.56 +function test_array_toString_sub_2()
    1.57 +{
    1.58 +  Object.defineProperty(arguments, "length", { value: 1 });
    1.59 +  assertEq([].toLocaleString.call(arguments), "1");
    1.60 +}
    1.61 +test_array_toString_sub_2(1, 2);
    1.62 +
    1.63 +
    1.64 +/******************************************************************************/
    1.65 +
    1.66 +reportCompare(true, true);
    1.67 +
    1.68 +print("All tests passed!");

mercurial