Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / kde / script-tests / function_arguments.js
blob664988cf189a8c1ce9cb09d802c24fa69e3c22c7
1 // check value of arguments inside recursion
3 var expected = [null,99,1,2,3,3,2,1,99,null];
4 var expno = 0;
6 var x = 0;
7 shouldBe("mf.arguments", "expected[expno++]");
8 function mf(a,b) {
9 shouldBe("mf.arguments[0]", "expected[expno++]");
10 x++;
11 if (x < 4)
12 mf(x,1);
13 shouldBe("mf.arguments[0]", "expected[expno++]");
14 return b;
16 mf(99);
17 shouldBe("mf.arguments", "expected[expno++]");
20 // check internal properties of arguments
22 // Delete
25 // DontEnum
26 var foundArgs = false;
28 var ReadOnlyOK = false;
29 var DontDeleteOK = false;
30 var DontEnumOK = false;
31 function f(a,b,c) {
33 // ReadOnly
34 var newargs = new Object();
35 f.arguments = newargs;
36 ReadOnlyOK = (f.arguments != newargs);
38 // DontDelete
39 DontDeleteOK = !delete(f.arguments);
40 if (f.arguments == undefined || !f.hasOwnProperty("arguments"))
41 DontDeleteOK = false;
43 // DontEnum
44 var foundArgs = false;
45 for (i in f) {
46 if (f == "arguments")
47 foundArgs = true;
49 DontEnumOK = !foundArgs;
51 f(1,2,3);
52 shouldBeTrue("ReadOnlyOK");
53 shouldBeTrue("DontDeleteOK");
54 shouldBeTrue("DontEnumOK");
56 // Check that parameter variables are bound to the corresponding
57 // elements in the arguments array
58 var arg0 = null;
59 var arg1 = null;
60 var arg2 = null;
61 var newarg0 = null;
62 var newarg1 = null;
63 var newarg2 = null;
64 var newx = null;
65 var arglength = 0;
67 function dupargs(x,x,x)
69 arg0 = arguments[0];
70 arg1 = arguments[1];
71 arg2 = arguments[2];
72 arglength = arguments.length;
73 x = 999;
74 newarg0 = arguments[0];
75 newarg1 = arguments[1];
76 newarg2 = arguments[2];
77 arguments[2] = 888;
78 newx = x;
81 dupargs(1,2,3);
83 shouldBe("arg0","1");
84 shouldBe("arg1","2");
85 shouldBe("arg2","3");
86 shouldBe("arglength","3");
87 shouldBe("newarg0","1");
88 shouldBe("newarg1","2");
89 shouldBe("newarg2","999");
90 shouldBe("newx","888");