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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
531 } | 531 } |
532 assertEquals(1, evalInFunctionHoisted()); | 532 assertEquals(1, evalInFunctionHoisted()); |
533 `); | 533 `); |
534 }(); | 534 }(); |
535 | 535 |
536 let dontHoistGlobal; | 536 let dontHoistGlobal; |
537 { function dontHoistGlobal() {} } | 537 { function dontHoistGlobal() {} } |
538 assertEquals(undefined, dontHoistGlobal); | 538 assertEquals(undefined, dontHoistGlobal); |
539 | 539 |
540 let dontHoistEval; | 540 let dontHoistEval; |
541 // BUG(v8:) This shouldn't hoist and shouldn't throw | |
542 var throws = false; | 541 var throws = false; |
543 try { | 542 try { |
544 eval("{ function dontHoistEval() {} }"); | 543 eval("{ function dontHoistEval() {} }"); |
545 } catch (e) { | 544 } catch (e) { |
546 throws = true; | 545 throws = true; |
547 } | 546 } |
548 assertTrue(throws); | 547 assertFalse(throws); |
549 | 548 |
550 // When the global object is frozen, silently don't hoist | 549 // When the global object is frozen, silently don't hoist |
551 // Currently this actually throws BUG(v8:4452) | |
552 Object.freeze(this); | 550 Object.freeze(this); |
553 throws = false; | 551 throws = false; |
554 try { | 552 try { |
555 eval('{ function hoistWhenFrozen() {} }'); | 553 eval('{ function hoistWhenFrozen() {} }'); |
556 } catch (e) { | 554 } catch (e) { |
557 throws = true; | 555 throws = true; |
558 } | 556 } |
559 assertFalse(this.hasOwnProperty("hoistWhenFrozen")); | 557 assertFalse(this.hasOwnProperty("hoistWhenFrozen")); |
560 assertThrows(() => hoistWhenFrozen, ReferenceError); | 558 assertThrows(() => hoistWhenFrozen, ReferenceError); |
561 // Should be assertFalse BUG(v8:4452) | 559 assertFalse(throws); |
Dan Ehrenberg
2016/07/01 01:36:20
This one's funny. Because the global object is alr
| |
562 assertTrue(throws); | |
OLD | NEW |