Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / script-tests / function-dot-arguments.js
blob304a56fd67c65553676c9cd692b58e2795049583
1 description(
2 "This test checks basic and corner cases of 'f.arguments'."
3 );
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'");
13 function lengthTest()
15 return "" + lengthTest.arguments.length;
17 shouldBe("lengthTest()", "'0'");
18 shouldBe("lengthTest('From', '%E5%8C%97%E4%BA%AC', 360, '/', 'webkit.org')", "'5'");
20 function assignTest()
22 function g()
24 return assignTest.arguments;
27 arguments = true;
28 return g();
30 shouldBe("assignTest().toString()", "'[object Arguments]'");
32 function assignVarUndefinedTest()
34 function g()
36 return assignVarUndefinedTest.arguments;
39 var arguments;
40 return g();
42 shouldBe("assignVarUndefinedTest().toString()", "'[object Arguments]'");
44 function assignVarUndefinedTest2()
46 function g()
48 return assignVarUndefinedTest2.arguments;
51 var a, arguments;
52 return g();
54 shouldBe("assignVarUndefinedTest2().toString()", "'[object Arguments]'");
56 function assignVarInitTest()
58 function g()
60 return assignVarInitTest.arguments;
63 var arguments = true;
64 return g();
66 shouldBe("assignVarInitTest().toString()", "'[object Arguments]'");
68 function assignVarInitTest2()
70 function g()
72 return assignVarInitTest2.arguments;
75 var a, arguments = true;
76 return g();
78 shouldBe("assignVarInitTest2().toString()", "'[object Arguments]'");
80 function assignConstUndefinedTest()
82 function g()
84 return assignConstUndefinedTest.arguments;
87 var arguments;
88 return g();
90 shouldBe("assignConstUndefinedTest().toString()", "'[object Arguments]'");
92 function assignConstUndefinedTest2()
94 function g()
96 return assignConstUndefinedTest2.arguments;
99 var a, arguments;
100 return g();
102 shouldBe("assignConstUndefinedTest2().toString()", "'[object Arguments]'");
104 function assignConstInitTest()
106 function g()
108 return assignConstInitTest.arguments;
111 const arguments = true;
112 return g();
114 shouldBe("assignConstInitTest().toString()", "'[object Arguments]'");
116 function assignConstInitTest2()
118 function g()
120 return assignConstInitTest2.arguments;
123 const a, arguments = true;
124 return g();
126 shouldBe("assignConstInitTest2().toString()", "'[object Arguments]'");
128 function assignForInitTest()
130 function g()
132 return assignForInitTest.arguments;
135 for (var arguments = true; false;) { }
136 return g();
138 shouldBe("assignForInitTest().toString()", "'[object Arguments]'");
140 function assignForInitTest2()
142 function g()
144 return assignForInitTest2.arguments;
147 for (var a, arguments = true; false;) { }
148 return g();
150 shouldBe("assignForInitTest2().toString()", "'[object Arguments]'");
152 function assignForInInitTest()
154 function g()
156 return assignForInInitTest.arguments;
159 for (arguments = true; false;) { }
160 return g();
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()
183 function g()
185 var a = 1;
186 return arguments;
189 var b = 2;
190 var arguments = g(true);
191 return arguments;
193 shouldBeTrue("tearOffTest()[0]");
195 function tearOffTest2()
197 function g(a)
199 var arguments = a;
200 var b = 2;
201 return arguments;
204 var c = 3;
205 return g(arguments);
207 shouldBeTrue("tearOffTest2(true)[0]");
209 function lexicalArgumentsLiveRead1(a, b, c)
211 var o = arguments;
212 a = 1;
213 return lexicalArgumentsLiveRead1.arguments[0];
215 shouldBe("lexicalArgumentsLiveRead1(0, 2, 3)", "1");
217 function lexicalArgumentsLiveRead2(a, b, c)
219 var o = arguments;
220 b = 2;
221 return lexicalArgumentsLiveRead2.arguments[1];
223 shouldBe("lexicalArgumentsLiveRead2(1, 0, 3)", "2");
225 function lexicalArgumentsLiveRead3(a, b, c)
227 var o = arguments;
228 c = 3;
229 return lexicalArgumentsLiveRead3.arguments[2];
231 shouldBe("lexicalArgumentsLiveRead3(1, 2, 0)", "3");
233 function lexicalArgumentsLiveWrite1(a, b, c)
235 var o = arguments;
236 lexicalArgumentsLiveWrite1.arguments[0] = 1;
237 return a;
239 shouldBe("lexicalArgumentsLiveWrite1(0, 2, 3)", "0");
241 function lexicalArgumentsLiveWrite2(a, b, c)
243 var o = arguments;
244 lexicalArgumentsLiveWrite2.arguments[1] = 2;
245 return b;
247 shouldBe("lexicalArgumentsLiveWrite2(1, 0, 3)", "0");
249 function lexicalArgumentsLiveWrite3(a, b, c)
251 var o = arguments;
252 lexicalArgumentsLiveWrite3.arguments[2] = 3;
253 return c;
255 shouldBe("lexicalArgumentsLiveWrite3(1, 2, 0)", "0");
257 function argumentsNotLiveRead1(a, b, c)
259 var o = argumentsNotLiveRead1.arguments;
260 a = 1;
261 return o[0];
263 shouldBe("argumentsNotLiveRead1(0, 2, 3)", "0");
265 function argumentsNotLiveRead2(a, b, c)
267 var o = argumentsNotLiveRead2.arguments;
268 b = 2;
269 return o[1];
271 shouldBe("argumentsNotLiveRead2(1, 0, 3)", "0");
273 function argumentsNotLiveRead3(a, b, c)
275 var o = argumentsNotLiveRead3.arguments;
276 c = 3;
277 return o[2];
279 shouldBe("argumentsNotLiveRead3(1, 2, 0)", "0");
281 function argumentsNotLiveWrite1(a, b, c)
283 argumentsNotLiveWrite1.arguments[0] = 1;
284 return a;
286 shouldBe("argumentsNotLiveWrite1(0, 2, 3)", "0");
288 function argumentsNotLiveWrite2(a, b, c)
290 argumentsNotLiveWrite2.arguments[1] = 2;
291 return b;
293 shouldBe("argumentsNotLiveWrite2(1, 0, 3)", "0");
295 function argumentsNotLiveWrite3(a, b, c)
297 argumentsNotLiveWrite3.arguments[2] = 3;
298 return c;
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");
310 return arguments;
313 function overwroteArgumentsInDynamicScope2() {
314 arguments = true;
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]'");