2 "This test checks basic and corner cases of 'f.arguments'."
5 function basicTest(args
)
7 return basicTest
.arguments
;
9 shouldBe("basicTest('one')[0]", "'one'");
10 shouldBeUndefined("basicTest('one')[2]");
11 shouldBe("basicTest('one', 'two', 'three')[1]", "'two'");
15 return "" + lengthTest
.arguments
.length
;
17 shouldBe("lengthTest()", "'0'");
18 shouldBe("lengthTest('From', '%E5%8C%97%E4%BA%AC', 360, '/', 'webkit.org')", "'5'");
24 return assignTest
.arguments
;
30 shouldBe("assignTest().toString()", "'[object Arguments]'");
32 function assignVarUndefinedTest()
36 return assignVarUndefinedTest
.arguments
;
42 shouldBe("assignVarUndefinedTest().toString()", "'[object Arguments]'");
44 function assignVarUndefinedTest2()
48 return assignVarUndefinedTest2
.arguments
;
54 shouldBe("assignVarUndefinedTest2().toString()", "'[object Arguments]'");
56 function assignVarInitTest()
60 return assignVarInitTest
.arguments
;
66 shouldBe("assignVarInitTest().toString()", "'[object Arguments]'");
68 function assignVarInitTest2()
72 return assignVarInitTest2
.arguments
;
75 var a
, arguments
= true;
78 shouldBe("assignVarInitTest2().toString()", "'[object Arguments]'");
80 function assignConstUndefinedTest()
84 return assignConstUndefinedTest
.arguments
;
90 shouldBe("assignConstUndefinedTest().toString()", "'[object Arguments]'");
92 function assignConstUndefinedTest2()
96 return assignConstUndefinedTest2
.arguments
;
102 shouldBe("assignConstUndefinedTest2().toString()", "'[object Arguments]'");
104 function assignConstInitTest()
108 return assignConstInitTest
.arguments
;
111 const arguments
= true;
114 shouldBe("assignConstInitTest().toString()", "'[object Arguments]'");
116 function assignConstInitTest2()
120 return assignConstInitTest2
.arguments
;
123 const a
, arguments
= true;
126 shouldBe("assignConstInitTest2().toString()", "'[object Arguments]'");
128 function assignForInitTest()
132 return assignForInitTest
.arguments
;
135 for (var arguments
= true; false;) { }
138 shouldBe("assignForInitTest().toString()", "'[object Arguments]'");
140 function assignForInitTest2()
144 return assignForInitTest2
.arguments
;
147 for (var a
, arguments
= true; false;) { }
150 shouldBe("assignForInitTest2().toString()", "'[object Arguments]'");
152 function assignForInInitTest()
156 return assignForInInitTest
.arguments
;
159 for (arguments
= true; false;) { }
162 shouldBe("assignForInInitTest().toString()", "'[object Arguments]'");
164 function paramInitTest(arguments
)
166 return paramInitTestCheckArguments();
168 function paramInitTestCheckArguments()
170 return paramInitTest
.arguments
;
172 shouldBe("paramInitTest(true).toString()", "'[object Arguments]'");
174 var paramFunctionConstructorInitTest
= Function("arguments", "return paramFunctionConstructorInitTestCheckArguments();");
175 function paramFunctionConstructorInitTestCheckArguments()
177 return paramFunctionConstructorInitTest
.arguments
;
179 shouldBe("paramFunctionConstructorInitTest(true).toString()", "'[object Arguments]'");
181 function tearOffTest()
190 var arguments
= g(true);
193 shouldBeTrue("tearOffTest()[0]");
195 function tearOffTest2()
207 shouldBeTrue("tearOffTest2(true)[0]");
209 function lexicalArgumentsLiveRead1(a
, b
, c
)
213 return lexicalArgumentsLiveRead1
.arguments
[0];
215 shouldBe("lexicalArgumentsLiveRead1(0, 2, 3)", "1");
217 function lexicalArgumentsLiveRead2(a
, b
, c
)
221 return lexicalArgumentsLiveRead2
.arguments
[1];
223 shouldBe("lexicalArgumentsLiveRead2(1, 0, 3)", "2");
225 function lexicalArgumentsLiveRead3(a
, b
, c
)
229 return lexicalArgumentsLiveRead3
.arguments
[2];
231 shouldBe("lexicalArgumentsLiveRead3(1, 2, 0)", "3");
233 function lexicalArgumentsLiveWrite1(a
, b
, c
)
236 lexicalArgumentsLiveWrite1
.arguments
[0] = 1;
239 shouldBe("lexicalArgumentsLiveWrite1(0, 2, 3)", "0");
241 function lexicalArgumentsLiveWrite2(a
, b
, c
)
244 lexicalArgumentsLiveWrite2
.arguments
[1] = 2;
247 shouldBe("lexicalArgumentsLiveWrite2(1, 0, 3)", "0");
249 function lexicalArgumentsLiveWrite3(a
, b
, c
)
252 lexicalArgumentsLiveWrite3
.arguments
[2] = 3;
255 shouldBe("lexicalArgumentsLiveWrite3(1, 2, 0)", "0");
257 function argumentsNotLiveRead1(a
, b
, c
)
259 var o
= argumentsNotLiveRead1
.arguments
;
263 shouldBe("argumentsNotLiveRead1(0, 2, 3)", "0");
265 function argumentsNotLiveRead2(a
, b
, c
)
267 var o
= argumentsNotLiveRead2
.arguments
;
271 shouldBe("argumentsNotLiveRead2(1, 0, 3)", "0");
273 function argumentsNotLiveRead3(a
, b
, c
)
275 var o
= argumentsNotLiveRead3
.arguments
;
279 shouldBe("argumentsNotLiveRead3(1, 2, 0)", "0");
281 function argumentsNotLiveWrite1(a
, b
, c
)
283 argumentsNotLiveWrite1
.arguments
[0] = 1;
286 shouldBe("argumentsNotLiveWrite1(0, 2, 3)", "0");
288 function argumentsNotLiveWrite2(a
, b
, c
)
290 argumentsNotLiveWrite2
.arguments
[1] = 2;
293 shouldBe("argumentsNotLiveWrite2(1, 0, 3)", "0");
295 function argumentsNotLiveWrite3(a
, b
, c
)
297 argumentsNotLiveWrite3
.arguments
[2] = 3;
300 shouldBe("argumentsNotLiveWrite3(1, 2, 0)", "0");
302 function argumentsIdentity()
304 return argumentsIdentity
.arguments
!= argumentsIdentity
.arguments
;
306 shouldBeTrue("argumentsIdentity()");
308 function overwroteArgumentsInDynamicScope1() {
309 eval("arguments = true");
313 function overwroteArgumentsInDynamicScope2() {
315 return eval("arguments");
318 function overwroteArgumentsInDynamicScope3() {
319 eval("arguments = true");
320 return overwroteArgumentsInDynamicScope3
.arguments
;
322 shouldBeTrue("overwroteArgumentsInDynamicScope1()");
323 shouldBeTrue("overwroteArgumentsInDynamicScope2()");
324 shouldBe("overwroteArgumentsInDynamicScope3().toString()", "'[object Arguments]'");