OLD | NEW |
---|---|
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 --harmony-sloppy | 5 // Flags: --harmony-classes --harmony-sloppy |
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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
770 }, ReferenceError); | 770 }, ReferenceError); |
771 | 771 |
772 assertThrows(function() { | 772 assertThrows(function() { |
773 (class x extends x {}); | 773 (class x extends x {}); |
774 }, ReferenceError); | 774 }, ReferenceError); |
775 | 775 |
776 assertThrows(function() { | 776 assertThrows(function() { |
777 var x = (class x extends x {}); | 777 var x = (class x extends x {}); |
778 }, ReferenceError); | 778 }, ReferenceError); |
779 })(); | 779 })(); |
780 | |
781 | |
782 (function TestSuperCallSyntacticRestriction() { | |
783 assertThrows(function() { | |
784 class C { | |
785 constructor() { | |
786 var y; | |
arv (Not doing code reviews)
2014/12/01 15:14:07
Why should this throw? I thought the design we agr
| |
787 super(); | |
788 } | |
789 }; new C(); | |
790 }, TypeError); | |
791 assertThrows(function() { | |
792 class C { | |
793 constructor() { | |
794 super(this.x); | |
795 } | |
796 }; new C(); | |
797 }, TypeError); | |
798 assertThrows(function() { | |
799 class C { | |
800 constructor() { | |
801 super(this); | |
802 } | |
803 }; new C(); | |
804 }, TypeError); | |
805 assertThrows(function() { | |
806 class C { | |
807 constructor() { | |
808 super(1, 2, Object.getPrototypeOf(this)); | |
809 } | |
810 }; new C(); | |
811 }, TypeError); | |
812 assertThrows(function() { | |
813 class C { | |
814 constructor() { | |
815 { super(1, 2); } | |
816 } | |
817 }; new C(); | |
818 }, TypeError); | |
819 assertThrows(function() { | |
820 class C { | |
821 constructor() { | |
822 if (1) super(); | |
823 } | |
824 }; new C(); | |
825 }, TypeError); | |
826 | |
827 class C1 extends Object { | |
828 constructor() { | |
829 'use strict'; | |
830 super(); | |
831 } | |
832 }; | |
833 new C1(); | |
834 | |
835 class C2 extends Object { | |
836 constructor() { | |
837 ; 'use strict';;;;; | |
838 super(); | |
839 } | |
840 }; | |
841 new C2(); | |
842 | |
843 class C3 extends Object { | |
844 constructor() { | |
845 ; 'use strict';;;;; | |
846 // This is a comment. | |
847 super(); | |
848 } | |
849 }; | |
850 new C3(); | |
851 }()); | |
arv (Not doing code reviews)
2014/12/01 15:14:07
Can you add a test for `super.method()` too?
clas
| |
OLD | NEW |