Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: test/mjsunit/es6/block-sloppy-function.js

Issue 2119933002: Reland of Add errors for declarations which conflict with catch parameters. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixes per Adam Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 448 }
449 assertEquals(5, f()); 449 assertEquals(5, f());
450 } 450 }
451 451
452 assertEquals(4, f()); 452 assertEquals(4, f());
453 } 453 }
454 454
455 assertEquals(4, f()); 455 assertEquals(4, f());
456 })(); 456 })();
457 457
458 // B.3.5 interacts with B.3.3 to allow this.
459 (function hoistingThroughSimpleCatch() {
460 assertEquals(undefined, f);
461
462 try {
463 throw 0;
464 } catch(f) {
465 {
466 assertEquals(4, f());
467
468 function f() {
469 return 4;
470 }
471
472 assertEquals(4, f());
473 }
474 }
475
476 assertEquals(4, f());
477 })();
478
479 (function noHoistingThroughComplexCatch() {
480 try {
481 throw 0;
482 } catch({f}) {
483 {
484 assertEquals(4, f());
485
486 function f() {
487 return 4;
488 }
489
490 assertEquals(4, f());
491 }
492 }
493
494 assertThrows(()=>f, ReferenceError);
495 })();
496
458 // Test that hoisting from blocks does happen in global scope 497 // Test that hoisting from blocks does happen in global scope
459 function globalHoisted() { return 0; } 498 function globalHoisted() { return 0; }
460 { 499 {
461 function globalHoisted() { return 1; } 500 function globalHoisted() { return 1; }
462 } 501 }
463 assertEquals(1, globalHoisted()); 502 assertEquals(1, globalHoisted());
464 503
465 // Also happens when not previously defined 504 // Also happens when not previously defined
466 assertEquals(undefined, globalUndefinedHoisted); 505 assertEquals(undefined, globalUndefinedHoisted);
467 { 506 {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 throws = false; 592 throws = false;
554 try { 593 try {
555 eval('{ function hoistWhenFrozen() {} }'); 594 eval('{ function hoistWhenFrozen() {} }');
556 } catch (e) { 595 } catch (e) {
557 throws = true; 596 throws = true;
558 } 597 }
559 assertFalse(this.hasOwnProperty("hoistWhenFrozen")); 598 assertFalse(this.hasOwnProperty("hoistWhenFrozen"));
560 assertThrows(() => hoistWhenFrozen, ReferenceError); 599 assertThrows(() => hoistWhenFrozen, ReferenceError);
561 // Should be assertFalse BUG(v8:4452) 600 // Should be assertFalse BUG(v8:4452)
562 assertTrue(throws); 601 assertTrue(throws);
OLDNEW
« no previous file with comments | « test/mjsunit/es6/block-conflicts-sloppy.js ('k') | test/mjsunit/es6/catch-parameter-redeclaration.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698