blob: b88984e237b35a8589ab4c68abe9de89099577eb [file] [log] [blame]
<p>This tests verifies access to captured arguments via an optimized-away arguments object.
</p>
<pre id="console"></pre>
<script>
function log(s)
{
document.getElementById("console").appendChild(document.createTextNode(s + "\r\n"));
}
function shouldBe(a, aDescription, b)
{
if (a == b) {
log("PASS: " + aDescription + " should be " + b + " and is.");
return;
}
log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
}
if (window.testRunner) {
testRunner.dumpAsText();
}
// In-bounds of declared and passed arguments, no activation, before tear-off.
function f0(x) {
return arguments[0] || function() { return x; };
}
// Out-of-bounds of declared arguments, in-bounds of passed arguments, no activation, before tear-off.
function f1(x) {
return arguments[1] || function() { return x; };
}
// In-bounds of declared arguments, in-bounds of passed arguments, yes activation, before tear-off.
function f2(x) {
return function() { return x; } && arguments[0];
}
// Out-of-bounds of declared arguments, in-bounds of passed arguments, yes activation, before tear-off.
function f3(x) {
return function() { return x; } && arguments[1];
}
// In-bounds of declared and passed arguments, no activation, after tear-off.
function f4(x) {
return arguments || function() { return x; };
}
// Out-of-bounds of declared arguments, in-bounds of passed arguments, no activation, after tear-off.
function f5(x) {
return arguments || function() { return x; };
}
// In-bounds of declared arguments, in-bounds of passed arguments, yes activation, after tear-off.
function f6(x) {
return function() { return x; } && arguments;
}
// Out-of-bounds of declared arguments, in-bounds of passed arguments, yes activation, after tear-off.
function f7(x) {
return function() { return x; } && arguments;
}
for (var i = 0; i < 200; ++i) {
shouldBe(f0(1), "f0(1)", 1);
shouldBe(f1(2, 3), "f1(2, 3)", 3);
shouldBe(f2(4), "f2(4)", 4);
shouldBe(f3(5, 6), "f3(5, 6)", 6);
shouldBe(f4(7)[0], "f4(7)", 7);
shouldBe(f5(8, 9)[1], "f5(8, 9)", 9);
shouldBe(f6(10)[0], "f6(10)", 10);
shouldBe(f7(11, 12)[1], "f7(11, 12)", 12);
}
</script>