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 args, self; | |
629 class Base { | |
630 constructor() { | |
Dmitry Lomov (no reviews)
2014/11/11 10:12:50
Add a test with constructor that takes arguments n
| |
631 self = this; | |
632 args = arguments; | |
633 } | |
634 } | |
635 class Derived extends Base {} | |
636 | |
637 new Derived; | |
638 assertEquals(0, args.length); | |
639 | |
640 new Derived(0, 1, 2); | |
641 assertEquals(3, args.length); | |
642 assertTrue(self instanceof Derived); | |
643 | |
644 var arr = new Array(1e5); | |
645 var obj = {}; | |
646 Derived.apply(obj, arr); | |
647 assertEquals(1e5, args.length); | |
648 assertEquals(obj, self); | |
649 })(); | |
650 | |
651 | |
627 /* TODO(arv): Implement | 652 /* TODO(arv): Implement |
628 (function TestNameBindingInConstructor() { | 653 (function TestNameBindingInConstructor() { |
629 class C { | 654 class C { |
630 constructor() { | 655 constructor() { |
631 assertThrows(function() { | 656 assertThrows(function() { |
632 C = 42; | 657 C = 42; |
633 }, ReferenceError); | 658 }, ReferenceError); |
634 } | 659 } |
635 } | 660 } |
636 new C(); | 661 new C(); |
637 })(); | 662 })(); |
638 */ | 663 */ |
OLD | NEW |