1 <p>This tests verifies access to captured arguments via an optimized-away arguments object.
3 <pre id=
"console"></pre>
8 document
.getElementById("console").appendChild(document
.createTextNode(s
+ "\r\n"));
11 function shouldBe(a
, aDescription
, b
)
14 log("PASS: " + aDescription
+ " should be " + b
+ " and is.");
17 log("FAIL: " + aDescription
+ " should be " + b
+ " but instead is " + a
+ ".");
20 if (window
.testRunner
) {
21 testRunner
.dumpAsText();
24 // In-bounds of declared and passed arguments, no activation, before tear-off.
26 return arguments
[0] || function() { return x
; };
29 // Out-of-bounds of declared arguments, in-bounds of passed arguments, no activation, before tear-off.
31 return arguments
[1] || function() { return x
; };
34 // In-bounds of declared arguments, in-bounds of passed arguments, yes activation, before tear-off.
36 return function() { return x
; } && arguments
[0];
39 // Out-of-bounds of declared arguments, in-bounds of passed arguments, yes activation, before tear-off.
41 return function() { return x
; } && arguments
[1];
44 // In-bounds of declared and passed arguments, no activation, after tear-off.
46 return arguments
|| function() { return x
; };
49 // Out-of-bounds of declared arguments, in-bounds of passed arguments, no activation, after tear-off.
51 return arguments
|| function() { return x
; };
54 // In-bounds of declared arguments, in-bounds of passed arguments, yes activation, after tear-off.
56 return function() { return x
; } && arguments
;
59 // Out-of-bounds of declared arguments, in-bounds of passed arguments, yes activation, after tear-off.
61 return function() { return x
; } && arguments
;
64 for (var i
= 0; i
< 200; ++i
) {
65 shouldBe(f0(1), "f0(1)", 1);
66 shouldBe(f1(2, 3), "f1(2, 3)", 3);
67 shouldBe(f2(4), "f2(4)", 4);
68 shouldBe(f3(5, 6), "f3(5, 6)", 6);
69 shouldBe(f4(7)[0], "f4(7)", 7);
70 shouldBe(f5(8, 9)[1], "f5(8, 9)", 9);
71 shouldBe(f6(10)[0], "f6(10)", 10);
72 shouldBe(f7(11, 12)[1], "f7(11, 12)", 12);