Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / dfg-arguments-alias-activation.html
blobb88984e237b35a8589ab4c68abe9de89099577eb
1 <p>This tests verifies access to captured arguments via an optimized-away arguments object.
2 </p>
3 <pre id="console"></pre>
5 <script>
6 function log(s)
8 document.getElementById("console").appendChild(document.createTextNode(s + "\r\n"));
11 function shouldBe(a, aDescription, b)
13 if (a == b) {
14 log("PASS: " + aDescription + " should be " + b + " and is.");
15 return;
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.
25 function f0(x) {
26 return arguments[0] || function() { return x; };
29 // Out-of-bounds of declared arguments, in-bounds of passed arguments, no activation, before tear-off.
30 function f1(x) {
31 return arguments[1] || function() { return x; };
34 // In-bounds of declared arguments, in-bounds of passed arguments, yes activation, before tear-off.
35 function f2(x) {
36 return function() { return x; } && arguments[0];
39 // Out-of-bounds of declared arguments, in-bounds of passed arguments, yes activation, before tear-off.
40 function f3(x) {
41 return function() { return x; } && arguments[1];
44 // In-bounds of declared and passed arguments, no activation, after tear-off.
45 function f4(x) {
46 return arguments || function() { return x; };
49 // Out-of-bounds of declared arguments, in-bounds of passed arguments, no activation, after tear-off.
50 function f5(x) {
51 return arguments || function() { return x; };
54 // In-bounds of declared arguments, in-bounds of passed arguments, yes activation, after tear-off.
55 function f6(x) {
56 return function() { return x; } && arguments;
59 // Out-of-bounds of declared arguments, in-bounds of passed arguments, yes activation, after tear-off.
60 function f7(x) {
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);
74 </script>