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 | 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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 class Derived extends Base {} | 617 class Derived extends Base {} |
618 var object = new Derived; | 618 var object = new Derived; |
619 assertEquals(1, calls); | 619 assertEquals(1, calls); |
620 | 620 |
621 calls = 0; | 621 calls = 0; |
622 Derived(); | 622 Derived(); |
623 assertEquals(1, calls); | 623 assertEquals(1, calls); |
624 })(); | 624 })(); |
625 | 625 |
626 | 626 |
| 627 (function TestDefaultConstructorArguments() { |
| 628 var calls = 0; |
| 629 var args, self; |
| 630 class Base { |
| 631 constructor() { |
| 632 self = this; |
| 633 args = arguments; |
| 634 } |
| 635 } |
| 636 class Derived extends Base {} |
| 637 |
| 638 new Derived; |
| 639 assertEquals(0, args.length); |
| 640 |
| 641 new Derived(0, 1, 2); |
| 642 assertEquals(3, args.length); |
| 643 assertTrue(self instanceof Derived); |
| 644 |
| 645 var arr = new Array(1e5); |
| 646 var obj = {}; |
| 647 Derived.apply(obj, arr); |
| 648 assertEquals(1e5, args.length); |
| 649 assertEquals(obj, self); |
| 650 })(); |
| 651 |
| 652 |
627 /* TODO(arv): Implement | 653 /* TODO(arv): Implement |
628 (function TestNameBindingInConstructor() { | 654 (function TestNameBindingInConstructor() { |
629 class C { | 655 class C { |
630 constructor() { | 656 constructor() { |
631 assertThrows(function() { | 657 assertThrows(function() { |
632 C = 42; | 658 C = 42; |
633 }, ReferenceError); | 659 }, ReferenceError); |
634 } | 660 } |
635 } | 661 } |
636 new C(); | 662 new C(); |
637 })(); | 663 })(); |
638 */ | 664 */ |
OLD | NEW |