summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Function/redefine-arguments-length.js
blob: ad9ae742ff28d446059a42e1b314ba886e9a6923 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/
 */

var gTestfile = 'redefine-arguments-length.js';
//-----------------------------------------------------------------------------
var BUGNUMBER = 539766;
var summary =
  "Object.defineProperty sets arguments.length without setting the " +
  "length-overridden bit";

print(BUGNUMBER + ": " + summary);

/**************
 * BEGIN TEST *
 **************/

function test_JSOP_ARGCNT()
{
  var length = "length";
  Object.defineProperty(arguments, length, { value: 17 });
  assertEq(arguments.length, 17);
  assertEq(arguments[length], 17);
}
test_JSOP_ARGCNT();

function test_js_fun_apply()
{
  var length = "length";
  Object.defineProperty(arguments, length, { value: 17 });

  function fun()
  {
    assertEq(arguments.length, 17);
    assertEq(arguments[length], 17);
    assertEq(arguments[0], "foo");
    for (var i = 1; i < 17; i++)
      assertEq(arguments[i], undefined);
  }
  fun.apply(null, arguments);
}
test_js_fun_apply("foo");

function test_array_toString_sub_1()
{
  Object.defineProperty(arguments, "length", { value: 1 });
  arguments.join = [].join;
  assertEq([].toString.call(arguments), "1");
}
test_array_toString_sub_1(1, 2);

function test_array_toString_sub_2()
{
  Object.defineProperty(arguments, "length", { value: 1 });
  assertEq([].toLocaleString.call(arguments), "1");
}
test_array_toString_sub_2(1, 2);


/******************************************************************************/

reportCompare(true, true);

print("All tests passed!");