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

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

mercurial