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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 | 676 |
677 new Derived(1, 2, 3); | 677 new Derived(1, 2, 3); |
678 assertEquals(3, args.length); | 678 assertEquals(3, args.length); |
679 assertEquals(1, args[0]); | 679 assertEquals(1, args[0]); |
680 assertEquals(2, args[1]); | 680 assertEquals(2, args[1]); |
681 assertEquals(3, args[2]); | 681 assertEquals(3, args[2]); |
682 })(); | 682 })(); |
683 | 683 |
684 | 684 |
685 (function TestNameBindingConst() { | 685 (function TestNameBindingConst() { |
686 assertThrows('class C { constructor() { C = 42; } }', SyntaxError); | 686 assertThrows('class C { constructor() { C = 42; } }; new C();', TypeError); |
687 assertThrows('(class C { constructor() { C = 42; } })', SyntaxError); | 687 assertThrows('new (class C { constructor() { C = 42; } })', TypeError); |
688 assertThrows('class C { m() { C = 42; } }', SyntaxError); | 688 assertThrows('class C { m() { C = 42; } }; new C().m()', TypeError); |
689 assertThrows('(class C { m() { C = 42; } })', SyntaxError); | 689 assertThrows('new (class C { m() { C = 42; } }).m()', TypeError); |
690 assertThrows('class C { get x() { C = 42; } }', SyntaxError); | 690 assertThrows('class C { get x() { C = 42; } }; new C().x', TypeError); |
691 assertThrows('(class C { get x() { C = 42; } })', SyntaxError); | 691 assertThrows('(new (class C { get x() { C = 42; } })).x', TypeError); |
692 assertThrows('class C { set x(_) { C = 42; } }', SyntaxError); | 692 assertThrows('class C { set x(_) { C = 42; } }; new C().x = 15;', TypeError); |
693 assertThrows('(class C { set x(_) { C = 42; } })', SyntaxError); | 693 assertThrows('(new (class C { set x(_) { C = 42; } })).x = 15;', TypeError); |
694 })(); | 694 })(); |
695 | 695 |
696 | 696 |
697 (function TestNameBinding() { | 697 (function TestNameBinding() { |
698 var C2; | 698 var C2; |
699 class C { | 699 class C { |
700 constructor() { | 700 constructor() { |
701 C2 = C; | 701 C2 = C; |
702 } | 702 } |
703 m() { | 703 m() { |
(...skipping 66 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 })(); |
OLD | NEW |