OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Test Annex B 3.3 semantics for functions declared in blocks in sloppy mode. | 5 // Test Annex B 3.3 semantics for functions declared in blocks in sloppy mode. |
6 // http://www.ecma-international.org/ecma-262/6.0/#sec-block-level-function-decl
arations-web-legacy-compatibility-semantics | 6 // http://www.ecma-international.org/ecma-262/6.0/#sec-block-level-function-decl
arations-web-legacy-compatibility-semantics |
7 | 7 |
8 (function overridingLocalFunction() { | 8 (function overridingLocalFunction() { |
9 var x = []; | 9 var x = []; |
10 assertEquals('function', typeof f); | 10 assertEquals('function', typeof f); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 let y = 3; | 60 let y = 3; |
61 function f() { | 61 function f() { |
62 y = 2; | 62 y = 2; |
63 } | 63 } |
64 f(); | 64 f(); |
65 assertEquals(2, y); | 65 assertEquals(2, y); |
66 } | 66 } |
67 assertEquals(1, f); | 67 assertEquals(1, f); |
68 })(); | 68 })(); |
69 | 69 |
| 70 (function shadowingLetDoesntBindGenerator() { |
| 71 let f = function *f() { |
| 72 while(true) { |
| 73 yield 1; |
| 74 } |
| 75 }; |
| 76 assertEquals(1, f().next().value); |
| 77 { |
| 78 function *f() { |
| 79 while(true) { |
| 80 yield 2; |
| 81 } |
| 82 } |
| 83 assertEquals(2, f().next().value); |
| 84 } |
| 85 assertEquals(1, f().next().value); |
| 86 })(); |
| 87 |
70 (function shadowingClassDoesntBind() { | 88 (function shadowingClassDoesntBind() { |
71 class f { } | 89 class f { } |
72 assertEquals('class f { }', f.toString()); | 90 assertEquals('class f { }', f.toString()); |
73 { | 91 { |
74 let y = 3; | 92 let y = 3; |
75 function f() { | 93 function f() { |
76 y = 2; | 94 y = 2; |
77 } | 95 } |
78 f(); | 96 f(); |
79 assertEquals(2, y); | 97 assertEquals(2, y); |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 try { | 665 try { |
648 eval('{ function hoistWhenFrozen() {} }'); | 666 eval('{ function hoistWhenFrozen() {} }'); |
649 } catch (e) { | 667 } catch (e) { |
650 throws = true; | 668 throws = true; |
651 } | 669 } |
652 assertFalse(this.hasOwnProperty("hoistWhenFrozen")); | 670 assertFalse(this.hasOwnProperty("hoistWhenFrozen")); |
653 assertThrows(() => hoistWhenFrozen, ReferenceError); | 671 assertThrows(() => hoistWhenFrozen, ReferenceError); |
654 // Should be assertFalse BUG(v8:4452) | 672 // Should be assertFalse BUG(v8:4452) |
655 assertTrue(throws); | 673 assertTrue(throws); |
656 } | 674 } |
OLD | NEW |