Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1 | // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 5 | (function f(){ |
| 6 | assertEquals("function", typeof f); |
| 7 | })(); |
| 8 | |
| 9 | (function f(){ |
| 10 | var f; // Variable shadows function name. |
| 11 | assertEquals("undefined", typeof f); |
| 12 | })(); |
| 13 | |
| 14 | (function f(){ |
| 15 | var f; |
| 16 | assertEquals("undefined", typeof f); |
| 17 | with ({}); // Force context allocation of both variable and function name. |
| 18 | })(); |
| 19 | |
| 20 | assertEquals("undefined", typeof f); |
| 21 | |
| 22 | // var initialization is intercepted by with scope. |
| 23 | (function() { |
| 24 | var o = { a: 1 }; |
| 25 | with (o) { |
| 26 | var a = 2; |
| 27 | } |
| 28 | assertEquals("undefined", typeof a); |
| 29 | assertEquals(2, o.a); |
| 30 | })(); |