Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Flags: --allow-natives-syntax --harmony-block-scoping | |
|
Kevin Millikin (Chromium)
2011/08/10 11:19:27
The test file needs a copyright notice.
Steven
2011/08/10 12:21:00
Done.
| |
| 2 | |
| 3 // Hoisting of var declarations. | |
| 4 function f1() { | |
| 5 { | |
| 6 var x = 1; | |
| 7 var y; | |
| 8 } | |
| 9 assertEquals(1, x) | |
| 10 assertEquals(undefined, y) | |
| 11 } | |
| 12 f1(); | |
| 13 | |
| 14 // Dynamic lookup through block scopes. | |
| 15 function f2(one) { | |
| 16 var x = one + 1; | |
| 17 // TODO(keuchel): introduce let | |
| 18 // let y = one + 2; | |
| 19 if (one == 1) { | |
| 20 // Parameter | |
| 21 assertEquals(1, eval('one')); | |
| 22 // Function local var variable | |
| 23 assertEquals(2, eval('x')); | |
| 24 // Function local let variable | |
| 25 // TODO(keuchel): introduce let | |
| 26 // assertEquals(3, eval('y')); | |
| 27 } | |
| 28 } | |
| 29 f2(); | |
| 30 | |
| OLD | NEW |