blob: d7b684dc367092b324e50c99cbbda840f5ae237c [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, printSuccess)
{
if (a == b) {
if (printSuccess)
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;
}
function doTest(printSuccess)
{
shouldBe(f0(1), "f0(1)", 1, printSuccess);
shouldBe(f1(2, 3), "f1(2, 3)", 3, printSuccess);
shouldBe(f2(4), "f2(4)", 4, printSuccess);
shouldBe(f3(5, 6), "f3(5, 6)", 6, printSuccess);
shouldBe(f4(7)[0], "f4(7)", 7, printSuccess);
shouldBe(f5(8, 9)[1], "f5(8, 9)", 9, printSuccess);
shouldBe(f6(10)[0], "f6(10)", 10, printSuccess);
shouldBe(f7(11, 12)[1], "f7(11, 12)", 12, printSuccess);
}
if (self.testRunner) {
var functions = [f0, f1, f2, f3, f4, f5, f6, f7];
for (var i = 0; i < functions.length; ++i)
testRunner.neverInlineFunction(functions[i]);
for (;;) {
var allCompiled = true;
for (var i = 0; i < functions.length; ++i) {
if (!testRunner.numberOfDFGCompiles(functions[i]))
allCompiled = false;
}
if (allCompiled)
break;
doTest(false);
}
}
doTest(true);
</script>