Chromium Code Reviews| 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() { | |
|
rossberg
2014/11/27 19:04:40
Add tests for nested calls, e.g.:
constructor()
Dmitry Lomov (no reviews)
2014/11/27 19:41:57
Done.
| |
| 783 assertThrows(function() { | |
| 784 class C { | |
| 785 constructor() { | |
| 786 var y; | |
| 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 | |
| 813 class C1 extends Object { | |
| 814 constructor() { | |
| 815 'use strict'; | |
| 816 super(); | |
| 817 } | |
| 818 }; | |
| 819 new C1(); | |
| 820 | |
| 821 class C2 extends Object { | |
| 822 constructor() { | |
| 823 ; 'use strict';;;;; | |
| 824 super(); | |
| 825 } | |
| 826 }; | |
| 827 new C2(); | |
| 828 | |
| 829 class C3 extends Object { | |
| 830 constructor() { | |
| 831 ; 'use strict';;;;; | |
| 832 // This is a comment. | |
| 833 super(); | |
| 834 } | |
| 835 }; | |
| 836 new C3(); | |
| 837 }()); | |
| OLD | NEW |