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

Side by Side Diff: test/mjsunit/harmony/classes.js

Issue 722793005: Classes: Implement correct name binding (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: git rebase Created 6 years, 1 month 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 | Annotate | Revision Log
« src/parser.cc ('K') | « src/preparser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 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 // Flags: --harmony-classes 5 // Flags: --harmony-classes
6 6
7 (function TestBasics() { 7 (function TestBasics() {
8 var C = class C {} 8 var C = class C {}
9 assertEquals(typeof C, 'function'); 9 assertEquals(typeof C, 'function');
10 assertEquals(C.__proto__, Function.prototype); 10 assertEquals(C.__proto__, Function.prototype);
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 assertEquals(1, args[0]); 666 assertEquals(1, args[0]);
667 667
668 new Derived(1, 2, 3); 668 new Derived(1, 2, 3);
669 assertEquals(3, args.length); 669 assertEquals(3, args.length);
670 assertEquals(1, args[0]); 670 assertEquals(1, args[0]);
671 assertEquals(2, args[1]); 671 assertEquals(2, args[1]);
672 assertEquals(3, args[2]); 672 assertEquals(3, args[2]);
673 })(); 673 })();
674 674
675 675
676 /* TODO(arv): Implement 676 (function TestNameBindingConst() {
677 (function TestNameBindingInConstructor() { 677 assertThrows('class C { constructor() { C = 42; } }', SyntaxError);
678 assertThrows('(class C { constructor() { C = 42; } })', SyntaxError);
679 assertThrows('class C { m() { C = 42; } }', SyntaxError);
680 assertThrows('(class C { m() { C = 42; } })', SyntaxError);
681 assertThrows('class C { get x() { C = 42; } }', SyntaxError);
682 assertThrows('(class C { get x() { C = 42; } })', SyntaxError);
683 assertThrows('class C { set x(_) { C = 42; } }', SyntaxError);
684 assertThrows('(class C { set x(_) { C = 42; } })', SyntaxError);
685 })();
686
687
688 (function TestNameBinding() {
689 var C2;
678 class C { 690 class C {
679 constructor() { 691 constructor() {
680 assertThrows(function() { 692 C2 = C;
681 C = 42; 693 }
682 }, ReferenceError); 694 m() {
695 C2 = C;
696 }
697 get x() {
698 C2 = C;
699 }
700 set x(_) {
701 C2 = C;
683 } 702 }
684 } 703 }
685 new C(); 704 new C();
705 assertEquals(C, C2);
706
707 C2 = undefined;
708 new C().m();
709 assertEquals(C, C2);
710
711 C2 = undefined;
712 new C().x;
713 assertEquals(C, C2);
714
715 C2 = undefined;
716 new C().x = 1;
717 assertEquals(C, C2);
686 })(); 718 })();
687 */ 719
720
721 (function TestNameBindingExpression() {
722 var C3;
723 var C = class C2 {
724 constructor() {
725 assertEquals(C2, C);
726 C3 = C2;
727 }
728 m() {
729 assertEquals(C2, C);
730 C3 = C2;
731 }
732 get x() {
733 assertEquals(C2, C);
734 C3 = C2;
735 }
736 set x(_) {
737 assertEquals(C2, C);
738 C3 = C2;
739 }
740 }
741 new C();
742 assertEquals(C, C3);
743
744 C3 = undefined;
745 new C().m();
746 assertEquals(C, C3);
747
748 C3 = undefined;
749 new C().x;
750 assertEquals(C, C3);
751
752 C3 = undefined;
753 new C().x = 1;
754 assertEquals(C, C3);
755 })();
756
757
758 (function TestNameBindingInExtendsExpression() {
759 assertThrows(function() {
760 class x extends x {}
761 }, ReferenceError);
762
763 assertThrows(function() {
764 (class x extends x {});
765 }, ReferenceError);
766
767 assertThrows(function() {
768 var x = (class x extends x {});
769 }, ReferenceError);
770 })();
OLDNEW
« src/parser.cc ('K') | « src/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698