fpizlo@apple.com | d554749 | 2012-06-07 00:23:36 +0000 | [diff] [blame] | 1 | description( |
| 2 | "Tests accessing arguments with an out-of-bounds index when the arguments have not been created but might be." |
| 3 | ); |
| 4 | |
| 5 | var p = false; |
| 6 | |
| 7 | function foo() { |
| 8 | function bar() { } |
| 9 | if (p) |
| 10 | return arguments; |
| 11 | return arguments[0]; |
| 12 | } |
| 13 | |
oliver@apple.com | 382f562 | 2013-07-25 04:01:50 +0000 | [diff] [blame] | 14 | silentTestPass = true; |
| 15 | noInline(foo); |
| 16 | |
fpizlo@apple.com | d554749 | 2012-06-07 00:23:36 +0000 | [diff] [blame] | 17 | var args = [42]; |
| 18 | var expected = "\"42\""; |
oliver@apple.com | 382f562 | 2013-07-25 04:01:50 +0000 | [diff] [blame] | 19 | for (var i = 0; i < 3000; i = dfgIncrement({f:foo, i:i + 1, n:1500})) { |
fpizlo@apple.com | d554749 | 2012-06-07 00:23:36 +0000 | [diff] [blame] | 20 | if (i == 1000) { |
| 21 | p = true; |
| 22 | expected = "\"[object Arguments]\""; |
| 23 | } |
| 24 | if (i == 2000) { |
| 25 | args = []; |
| 26 | p = false; |
| 27 | expected = "\"undefined\""; |
| 28 | } |
| 29 | result = "" +foo.apply(void 0, args); |
| 30 | shouldBe("result", expected); |
| 31 | } |
| 32 | |