Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / tests / ecma_5 / Function / redefine-arguments-length.js
1 /*
2  * Any copyright is dedicated to the Public Domain.
3  * http://creativecommons.org/licenses/publicdomain/
4  */
5
6 var gTestfile = 'redefine-arguments-length.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 539766;
9 var summary =
10   "Object.defineProperty sets arguments.length without setting the " +
11   "length-overridden bit";
12
13 print(BUGNUMBER + ": " + summary);
14
15 /**************
16  * BEGIN TEST *
17  **************/
18
19 function test_JSOP_ARGCNT()
20 {
21   var length = "length";
22   Object.defineProperty(arguments, length, { value: 17 });
23   assertEq(arguments.length, 17);
24   assertEq(arguments[length], 17);
25 }
26 test_JSOP_ARGCNT();
27
28 function test_js_fun_apply()
29 {
30   var length = "length";
31   Object.defineProperty(arguments, length, { value: 17 });
32
33   function fun()
34   {
35     assertEq(arguments.length, 17);
36     assertEq(arguments[length], 17);
37     assertEq(arguments[0], "foo");
38     for (var i = 1; i < 17; i++)
39       assertEq(arguments[i], undefined);
40   }
41   fun.apply(null, arguments);
42 }
43 test_js_fun_apply("foo");
44
45 function test_array_toString_sub_1()
46 {
47   Object.defineProperty(arguments, "length", { value: 1 });
48   arguments.join = [].join;
49   assertEq([].toString.call(arguments), "1");
50 }
51 test_array_toString_sub_1(1, 2);
52
53 function test_array_toString_sub_2()
54 {
55   Object.defineProperty(arguments, "length", { value: 1 });
56   assertEq([].toLocaleString.call(arguments), "1");
57 }
58 test_array_toString_sub_2(1, 2);
59
60
61 /******************************************************************************/
62
63 reportCompare(true, true);
64
65 print("All tests passed!");