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 | 7 |
8 (function TestSuperNamedLoads() { | 8 (function TestSuperNamedLoads() { |
9 function Base() { } | 9 function Base() { } |
10 function Derived() { | 10 function Derived() { |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
653 Object.defineProperty(d, 'ownReadOnly', { value : 42, writable : false }); | 653 Object.defineProperty(d, 'ownReadOnly', { value : 42, writable : false }); |
654 Object.defineProperty(d, 'ownSetter', | 654 Object.defineProperty(d, 'ownSetter', |
655 { set : function() { setterCalled++; } }); | 655 { set : function() { setterCalled++; } }); |
656 Object.defineProperty(d, 'ownReadonlyAccessor', | 656 Object.defineProperty(d, 'ownReadonlyAccessor', |
657 { get : function() { return 15; }}); | 657 { get : function() { return 15; }}); |
658 d.mSloppy(); | 658 d.mSloppy(); |
659 d.mStrict(); | 659 d.mStrict(); |
660 }()); | 660 }()); |
661 | 661 |
662 | 662 |
663 (function TestSetterInForIn() { | |
664 var setCalled = 0; | |
665 var getCalled = 0; | |
666 function Base() {} | |
667 Base.prototype = { | |
668 constructor: Base, | |
669 get x() { | |
670 getCalled++; | |
671 return 1; | |
672 }, | |
673 set x(v) { | |
674 setCalled++; | |
675 this.x_.push(v); | |
676 }, | |
677 }; | |
678 | |
679 function Derived() { | |
680 this.x_ = []; | |
681 } | |
682 Derived.prototype = { | |
683 __proto__: Base.prototype, | |
684 constructor: Derived, | |
685 }; | |
686 | |
687 Derived.prototype.testIter = function() { | |
688 setCalled = 0; | |
689 getCalled = 0; | |
690 for (super.x in [1,2,3]) {} | |
691 assertEquals(0, getCalled); | |
692 assertEquals(3, setCalled); | |
693 assertEquals(["0","1","2"], this.x_); | |
694 }.toMethod(Derived.prototype); | |
695 | |
696 new Derived().testIter(); | |
697 | |
698 var x = 'x'; | |
699 Derived.prototype.testIterKeyed = function() { | |
700 setCalled = 0; | |
701 getCalled = 0; | |
702 for (super[x] in [1,2,3]) {} | |
703 assertEquals(0, getCalled); | |
704 assertEquals(3, setCalled); | |
705 assertEquals(["0","1","2"], this.x_); | |
706 }.toMethod(Derived.prototype); | |
707 | |
708 new Derived().testIterKeyed(); | |
709 }()); | |
710 | |
Igor Sheludko
2014/10/13 11:39:07
Does it make sense to test keyed access via object
Dmitry Lomov (no reviews)
2014/10/13 12:39:51
Done.
| |
711 | |
663 (function TestKeyedSetterCreatingOwnProperties() { | 712 (function TestKeyedSetterCreatingOwnProperties() { |
664 var ownReadOnly = 'ownReadOnly'; | 713 var ownReadOnly = 'ownReadOnly'; |
665 var ownReadonlyAccessor = 'ownReadonlyAccessor'; | 714 var ownReadonlyAccessor = 'ownReadonlyAccessor'; |
666 var ownSetter = 'ownSetter'; | 715 var ownSetter = 'ownSetter'; |
667 function Base() {} | 716 function Base() {} |
668 function Derived() {} | 717 function Derived() {} |
669 Derived.prototype = { __proto__ : Base.prototype }; | 718 Derived.prototype = { __proto__ : Base.prototype }; |
670 var setterCalled; | 719 var setterCalled; |
671 | 720 |
672 Derived.prototype.mSloppy = function() { | 721 Derived.prototype.mSloppy = function() { |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1095 }()); | 1144 }()); |
1096 | 1145 |
1097 | 1146 |
1098 (function TestUnsupportedCases() { | 1147 (function TestUnsupportedCases() { |
1099 function f1(x) { return super[x]; } | 1148 function f1(x) { return super[x]; } |
1100 function f2(x) { super[x] = 5; } | 1149 function f2(x) { super[x] = 5; } |
1101 var o = {}; | 1150 var o = {}; |
1102 assertThrows(function(){f1.toMethod(o)(15);}, ReferenceError); | 1151 assertThrows(function(){f1.toMethod(o)(15);}, ReferenceError); |
1103 assertThrows(function(){f2.toMethod(o)(15);}, ReferenceError); | 1152 assertThrows(function(){f2.toMethod(o)(15);}, ReferenceError); |
1104 }()); | 1153 }()); |
OLD | NEW |