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 --allow-natives-syntax | 5 // Flags: --harmony-classes --allow-natives-syntax |
| 6 | 6 |
| 7 (function TestSuperNamedLoads() { | 7 (function TestSuperNamedLoads() { |
| 8 function Base() { } | 8 function Base() { } |
| 9 function fBase() { } | 9 function fBase() { } |
| 10 Base.prototype = { | 10 Base.prototype = { |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 588 }; | 588 }; |
| 589 | 589 |
| 590 function Derived() {} | 590 function Derived() {} |
| 591 Derived.prototype = { | 591 Derived.prototype = { |
| 592 __proto__: Base.prototype, | 592 __proto__: Base.prototype, |
| 593 constructor: Derived, | 593 constructor: Derived, |
| 594 testSetter() { | 594 testSetter() { |
| 595 setCalled = 0; | 595 setCalled = 0; |
| 596 getCalled = 0; | 596 getCalled = 0; |
| 597 assertEquals('object', typeof this); | 597 assertEquals('object', typeof this); |
| 598 assertTrue(this instanceof Number) | 598 assertInstanceof(this, Number) |
| 599 assertEquals(42, this.valueOf()); | 599 assertEquals(42, this.valueOf()); |
| 600 assertEquals(1, super.x); | 600 assertEquals(1, super.x); |
| 601 assertEquals(1, getCalled); | 601 assertEquals(1, getCalled); |
| 602 assertEquals(0, setCalled); | 602 assertEquals(0, setCalled); |
| 603 | 603 |
| 604 assertEquals(5, super.x = 5); | 604 assertEquals(5, super.x = 5); |
| 605 assertEquals(1, getCalled); | 605 assertEquals(1, getCalled); |
| 606 assertEquals(1, setCalled); | 606 assertEquals(1, setCalled); |
| 607 | 607 |
| 608 assertEquals(6, super.x += 5); | 608 assertEquals(6, super.x += 5); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 628 assertEquals(1, setCalled); | 628 assertEquals(1, setCalled); |
| 629 | 629 |
| 630 assertEquals(6, super.x += 5); | 630 assertEquals(6, super.x += 5); |
| 631 assertEquals(2, getCalled); | 631 assertEquals(2, getCalled); |
| 632 assertEquals(2, setCalled); | 632 assertEquals(2, setCalled); |
| 633 | 633 |
| 634 var ex; | 634 var ex; |
| 635 try { | 635 try { |
| 636 super.newProperty = 15; | 636 super.newProperty = 15; |
| 637 } catch (e) { ex = e; } | 637 } catch (e) { ex = e; } |
| 638 assertTrue(ex instanceof TypeError); | 638 assertInstanceof(ex, TypeError); |
| 639 } | 639 } |
| 640 } | 640 } |
| 641 | 641 |
| 642 Derived.prototype.testSetter.call(42); | 642 Derived.prototype.testSetter.call(42); |
| 643 Derived.prototype.testSetterStrict.call(42); | 643 Derived.prototype.testSetterStrict.call(42); |
| 644 | 644 |
| 645 function DerivedFromString() {} | 645 function DerivedFromString() {} |
| 646 DerivedFromString.prototype = { | 646 DerivedFromString.prototype = { |
| 647 __proto__: String.prototype, | 647 __proto__: String.prototype, |
| 648 f() { | 648 f() { |
| 649 'use strict'; | 649 'use strict'; |
| 650 assertTrue(42 === this); | 650 assertTrue(42 === this); |
| 651 assertEquals(String.prototype.toString, super.toString); | 651 assertEquals(String.prototype.toString, super.toString); |
| 652 var ex; | 652 var ex; |
| 653 try { | 653 try { |
| 654 super.toString(); | 654 super.toString(); |
| 655 } catch(e) { ex = e; } | 655 } catch(e) { ex = e; } |
| 656 | 656 |
| 657 assertTrue(ex instanceof TypeError); | 657 assertInstanceof(ex, TypeError); |
| 658 } | 658 } |
| 659 }; | 659 }; |
| 660 | 660 |
| 661 DerivedFromString.prototype.f.call(42); | 661 DerivedFromString.prototype.f.call(42); |
| 662 }()); | 662 }()); |
| 663 | 663 |
| 664 | 664 |
| 665 (function TestKeyedAccessorsOnPrimitives() { | 665 (function TestKeyedAccessorsOnPrimitives() { |
| 666 var x = 'x'; | 666 var x = 'x'; |
| 667 var newProperty = 'newProperty'; | 667 var newProperty = 'newProperty'; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 682 }; | 682 }; |
| 683 | 683 |
| 684 function Derived() {} | 684 function Derived() {} |
| 685 Derived.prototype = { | 685 Derived.prototype = { |
| 686 __proto__: Base.prototype, | 686 __proto__: Base.prototype, |
| 687 constructor: Derived, | 687 constructor: Derived, |
| 688 testSetter() { | 688 testSetter() { |
| 689 setCalled = 0; | 689 setCalled = 0; |
| 690 getCalled = 0; | 690 getCalled = 0; |
| 691 assertEquals('object', typeof this); | 691 assertEquals('object', typeof this); |
| 692 assertTrue(this instanceof Number) | 692 assertInstanceof(this, Number) |
| 693 assertEquals(42, this.valueOf()); | 693 assertEquals(42, this.valueOf()); |
| 694 assertEquals(1, super[x]); | 694 assertEquals(1, super[x]); |
| 695 assertEquals(1, getCalled); | 695 assertEquals(1, getCalled); |
| 696 assertEquals(0, setCalled); | 696 assertEquals(0, setCalled); |
| 697 | 697 |
| 698 assertEquals(5, super[x] = 5); | 698 assertEquals(5, super[x] = 5); |
| 699 assertEquals(1, getCalled); | 699 assertEquals(1, getCalled); |
| 700 assertEquals(1, setCalled); | 700 assertEquals(1, setCalled); |
| 701 | 701 |
| 702 assertEquals(6, super[x] += 5); | 702 assertEquals(6, super[x] += 5); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 722 assertEquals(1, setCalled); | 722 assertEquals(1, setCalled); |
| 723 | 723 |
| 724 assertEquals(6, super[x] += 5); | 724 assertEquals(6, super[x] += 5); |
| 725 assertEquals(2, getCalled); | 725 assertEquals(2, getCalled); |
| 726 assertEquals(2, setCalled); | 726 assertEquals(2, setCalled); |
| 727 | 727 |
| 728 var ex; | 728 var ex; |
| 729 try { | 729 try { |
| 730 super[newProperty] = 15; | 730 super[newProperty] = 15; |
| 731 } catch (e) { ex = e; } | 731 } catch (e) { ex = e; } |
| 732 assertTrue(ex instanceof TypeError); | 732 assertInstanceof(ex,TypeError); |
| 733 } | 733 } |
| 734 }; | 734 }; |
| 735 | 735 |
| 736 Derived.prototype.testSetter.call(42); | 736 Derived.prototype.testSetter.call(42); |
| 737 Derived.prototype.testSetterStrict.call(42); | 737 Derived.prototype.testSetterStrict.call(42); |
| 738 | 738 |
| 739 function DerivedFromString() {} | 739 function DerivedFromString() {} |
| 740 DerivedFromString.prototype = { | 740 DerivedFromString.prototype = { |
| 741 __proto__: String.prototype, | 741 __proto__: String.prototype, |
| 742 f() { | 742 f() { |
| 743 'use strict'; | 743 'use strict'; |
| 744 assertTrue(42 === this); | 744 assertTrue(42 === this); |
| 745 assertEquals(String.prototype.toString, super[toString]); | 745 assertEquals(String.prototype.toString, super[toString]); |
| 746 var ex; | 746 var ex; |
| 747 try { | 747 try { |
| 748 super[toString](); | 748 super[toString](); |
| 749 } catch(e) { ex = e; } | 749 } catch(e) { ex = e; } |
| 750 | 750 |
| 751 assertTrue(ex instanceof TypeError); | 751 assertInstanceof(ex, TypeError); |
| 752 } | 752 } |
| 753 }; | 753 }; |
| 754 DerivedFromString.prototype.f.call(42); | 754 DerivedFromString.prototype.f.call(42); |
| 755 }()); | 755 }()); |
| 756 | 756 |
| 757 | 757 |
| 758 (function TestNumericKeyedAccessorsOnPrimitives() { | 758 (function TestNumericKeyedAccessorsOnPrimitives() { |
| 759 var x = 42; | 759 var x = 42; |
| 760 var newProperty = 43; | 760 var newProperty = 43; |
| 761 var getCalled = 0; | 761 var getCalled = 0; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 777 }); | 777 }); |
| 778 | 778 |
| 779 function Derived() {} | 779 function Derived() {} |
| 780 Derived.prototype = { | 780 Derived.prototype = { |
| 781 __proto__: Base.prototype, | 781 __proto__: Base.prototype, |
| 782 constructor: Derived, | 782 constructor: Derived, |
| 783 testSetter() { | 783 testSetter() { |
| 784 setCalled = 0; | 784 setCalled = 0; |
| 785 getCalled = 0; | 785 getCalled = 0; |
| 786 assertEquals('object', typeof this); | 786 assertEquals('object', typeof this); |
| 787 assertTrue(this instanceof Number) | 787 assertInstanceof(this, Number) |
| 788 assertEquals(42, this.valueOf()); | 788 assertEquals(42, this.valueOf()); |
| 789 assertEquals(1, super[x]); | 789 assertEquals(1, super[x]); |
| 790 assertEquals(1, getCalled); | 790 assertEquals(1, getCalled); |
| 791 assertEquals(0, setCalled); | 791 assertEquals(0, setCalled); |
| 792 | 792 |
| 793 assertEquals(5, super[x] = 5); | 793 assertEquals(5, super[x] = 5); |
| 794 assertEquals(1, getCalled); | 794 assertEquals(1, getCalled); |
| 795 assertEquals(1, setCalled); | 795 assertEquals(1, setCalled); |
| 796 | 796 |
| 797 assertEquals(6, super[x] += 5); | 797 assertEquals(6, super[x] += 5); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 817 assertEquals(1, setCalled); | 817 assertEquals(1, setCalled); |
| 818 | 818 |
| 819 assertEquals(6, super[x] += 5); | 819 assertEquals(6, super[x] += 5); |
| 820 assertEquals(2, getCalled); | 820 assertEquals(2, getCalled); |
| 821 assertEquals(2, setCalled); | 821 assertEquals(2, setCalled); |
| 822 | 822 |
| 823 var ex; | 823 var ex; |
| 824 try { | 824 try { |
| 825 super[newProperty] = 15; | 825 super[newProperty] = 15; |
| 826 } catch (e) { ex = e; } | 826 } catch (e) { ex = e; } |
| 827 assertTrue(ex instanceof TypeError); | 827 assertInstanceof(ex, TypeError); |
| 828 } | 828 } |
| 829 }; | 829 }; |
| 830 | 830 |
| 831 Derived.prototype.testSetter.call(42); | 831 Derived.prototype.testSetter.call(42); |
| 832 Derived.prototype.testSetterStrict.call(42); | 832 Derived.prototype.testSetterStrict.call(42); |
| 833 }()); | 833 }()); |
| 834 | 834 |
| 835 | 835 |
| 836 (function TestKeyedNumericSetterOnExotics() { | 836 (function TestKeyedNumericSetterOnExotics() { |
| 837 function Base() {} | 837 function Base() {} |
| 838 function Derived() {} | 838 function Derived() {} |
| 839 Derived.prototype = { | 839 Derived.prototype = { |
| 840 __proto__: Base.prototype, | 840 __proto__: Base.prototype, |
| 841 callSetterOnArray() { | 841 callSetterOnArray() { |
| 842 super[42] = 1; | 842 super[42] = 1; |
| 843 }, | 843 }, |
| 844 callStrictSetterOnString() { | 844 callStrictSetterOnString() { |
| 845 'use strict'; | 845 'use strict'; |
| 846 assertEquals('string', typeof this); | 846 assertEquals('string', typeof this); |
| 847 assertTrue('abcdef' === this); | 847 assertTrue('abcdef' === this); |
| 848 var ex = null; | 848 var ex = null; |
| 849 try { | 849 try { |
| 850 super[5] = 'q'; | 850 super[5] = 'q'; |
| 851 } catch(e) { ex = e; } | 851 } catch(e) { ex = e; } |
| 852 assertTrue(ex instanceof TypeError); | 852 assertInstanceof(ex, TypeError); |
| 853 | 853 |
| 854 ex = null; | 854 ex = null; |
| 855 try { | 855 try { |
| 856 super[1024] = 'q'; | 856 super[1024] = 'q'; |
| 857 } catch(e) { ex = e; } | 857 } catch(e) { ex = e; } |
| 858 assertTrue(ex instanceof TypeError); | 858 assertInstanceof(ex, TypeError); |
| 859 } | 859 } |
| 860 }; | 860 }; |
| 861 | 861 |
| 862 var x = []; | 862 var x = []; |
| 863 assertEquals(0, x.length); | 863 assertEquals(0, x.length); |
| 864 Derived.prototype.callSetterOnArray.call(x); | 864 Derived.prototype.callSetterOnArray.call(x); |
| 865 assertEquals(43, x.length); | 865 assertEquals(43, x.length); |
| 866 assertEquals(1, x[42]); | 866 assertEquals(1, x[42]); |
| 867 | 867 |
| 868 var s = 'abcdef'; | 868 var s = 'abcdef'; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 956 }; | 956 }; |
| 957 var d = new Derived(); | 957 var d = new Derived(); |
| 958 d.mSloppy(); | 958 d.mSloppy(); |
| 959 assertEquals(10, d[x]); | 959 assertEquals(10, d[x]); |
| 960 var d1 = new Derived(); | 960 var d1 = new Derived(); |
| 961 d1.mStrict(); | 961 d1.mStrict(); |
| 962 assertEquals(10, d[x]); | 962 assertEquals(10, d[x]); |
| 963 }()); | 963 }()); |
| 964 | 964 |
| 965 | 965 |
| 966 (function TestSetterCreatingOwnProperties() { | 966 (function TestSetterCreatingOwnPropertiesReconfigurable() { |
| 967 var setterCalled; | |
| 968 function Base() {} | 967 function Base() {} |
| 969 function Derived() {} | 968 function Derived() {} |
| 970 Derived.prototype = { | 969 Derived.prototype = { |
| 970 __proto__: Base.prototype, | |
| 971 mSloppy() { | |
| 972 assertEquals(42, this.ownReadOnly); | |
| 973 super.ownReadOnly = 55; | |
| 974 assertEquals(55, this.ownReadOnly); | |
| 975 var descr = Object.getOwnPropertyDescriptor(this, 'ownReadOnly'); | |
| 976 assertEquals(55, descr.value); | |
| 977 assertTrue(descr.configurable); | |
| 978 assertFalse(descr.enumerable); | |
| 979 assertFalse(descr.writable); | |
| 980 assertFalse(Base.prototype.hasOwnProperty('ownReadOnly')); | |
| 981 | |
| 982 assertEquals(15, this.ownReadonlyAccessor); | |
| 983 super.ownReadonlyAccessor = 25; | |
| 984 assertEquals(25, this.ownReadonlyAccessor); | |
| 985 var descr = Object.getOwnPropertyDescriptor(this, 'ownReadonlyAccessor'); | |
| 986 assertEquals(25, descr.value); | |
| 987 assertTrue(descr.configurable); | |
| 988 assertFalse(descr.enumerable); | |
| 989 assertTrue(descr.writable); | |
| 990 assertFalse(Base.prototype.hasOwnProperty('ownReadonlyAccessor')); | |
| 991 | |
| 992 super.ownSetter = 35; | |
| 993 assertEquals(35, this.ownSetter); | |
| 994 var descr = Object.getOwnPropertyDescriptor(this, 'ownSetter'); | |
| 995 assertEquals(35, descr.value); | |
| 996 assertTrue(descr.configurable); | |
| 997 assertFalse(descr.enumerable); | |
| 998 assertTrue(descr.writable); | |
| 999 assertFalse(Base.prototype.hasOwnProperty('ownSetter')); | |
| 1000 }, | |
| 1001 mStrict() { | |
| 1002 'use strict'; | |
| 1003 assertEquals(42, this.ownReadOnly); | |
| 1004 super.ownReadOnly = 55; | |
| 1005 assertEquals(55, this.ownReadOnly); | |
| 1006 var descr = Object.getOwnPropertyDescriptor(this, 'ownReadOnly'); | |
| 1007 assertEquals(55, descr.value); | |
| 1008 assertTrue(descr.configurable); | |
| 1009 assertFalse(descr.enumerable); | |
| 1010 assertFalse(descr.writable); | |
| 1011 assertFalse(Base.prototype.hasOwnProperty('ownReadOnly')); | |
| 1012 | |
| 1013 assertEquals(15, this.ownReadonlyAccessor); | |
| 1014 super.ownReadonlyAccessor = 25; | |
| 1015 assertEquals(25, this.ownReadonlyAccessor); | |
| 1016 var descr = Object.getOwnPropertyDescriptor(this, 'ownReadonlyAccessor'); | |
| 1017 assertEquals(25, descr.value); | |
| 1018 assertTrue(descr.configurable); | |
| 1019 assertFalse(descr.enumerable); | |
| 1020 assertTrue(descr.writable); | |
| 1021 assertFalse(Base.prototype.hasOwnProperty('ownReadonlyAccessor')); | |
| 1022 | |
| 1023 super.ownSetter = 35; | |
| 1024 assertEquals(35, this.ownSetter); | |
| 1025 var descr = Object.getOwnPropertyDescriptor(this, 'ownSetter'); | |
| 1026 assertEquals(35, descr.value); | |
| 1027 assertTrue(descr.configurable); | |
| 1028 assertFalse(descr.enumerable); | |
| 1029 assertTrue(descr.writable); | |
| 1030 assertFalse(Base.prototype.hasOwnProperty('ownSetter')); | |
| 1031 }, | |
| 1032 }; | |
| 1033 | |
| 1034 var d = new Derived(); | |
| 1035 Object.defineProperty(d, 'ownReadOnly', { | |
| 1036 value: 42, | |
| 1037 writable: false, | |
| 1038 configurable: true | |
| 1039 }); | |
| 1040 Object.defineProperty(d, 'ownSetter', { | |
| 1041 set: function() { assertUnreachable(); }, | |
| 1042 configurable: true | |
| 1043 }); | |
| 1044 Object.defineProperty(d, 'ownReadonlyAccessor', { | |
| 1045 get: function() { return 15; }, | |
| 1046 configurable: true | |
| 1047 }); | |
| 1048 | |
| 1049 d.mSloppy(); | |
| 1050 | |
| 1051 var d = new Derived(); | |
| 1052 Object.defineProperty(d, 'ownReadOnly', { | |
| 1053 value: 42, | |
| 1054 writable: false, | |
| 1055 configurable: true | |
| 1056 }); | |
| 1057 Object.defineProperty(d, 'ownSetter', { | |
| 1058 set: function() { assertUnreachable(); }, | |
| 1059 configurable: true | |
| 1060 }); | |
| 1061 Object.defineProperty(d, 'ownReadonlyAccessor', { | |
| 1062 get: function() { return 15; }, | |
| 1063 configurable: true | |
| 1064 }); | |
| 1065 d.mStrict(); | |
| 1066 }()); | |
| 1067 | |
| 1068 | |
| 1069 (function TestSetterCreatingOwnPropertiesNonConfigurable() { | |
| 1070 function Base() {} | |
| 1071 function Derived() {} | |
| 1072 Derived.prototype = { | |
| 971 __proto__: Base.prototype, | 1073 __proto__: Base.prototype, |
| 972 mSloppy() { | 1074 mSloppy() { |
| 973 assertEquals(42, this.ownReadOnly); | 1075 assertEquals(42, this.ownReadOnly); |
| 974 super.ownReadOnly = 55; | 1076 super.ownReadOnly = 55; |
| 975 assertEquals(42, this.ownReadOnly); | 1077 assertEquals(42, this.ownReadOnly); |
| 1078 var descr = Object.getOwnPropertyDescriptor(this, 'ownReadOnly'); | |
| 1079 assertEquals(42, descr.value); | |
| 1080 assertFalse(descr.configurable); | |
| 1081 assertFalse(descr.enumerable); | |
| 1082 assertFalse(descr.writable); | |
| 1083 assertFalse(Base.prototype.hasOwnProperty('ownReadOnly')); | |
| 976 | 1084 |
| 1085 var ex; | |
| 977 assertEquals(15, this.ownReadonlyAccessor); | 1086 assertEquals(15, this.ownReadonlyAccessor); |
| 978 super.ownReadonlyAccessor = 55; | 1087 try { |
| 1088 super.ownReadonlyAccessor = 25; | |
| 1089 } catch (e) { | |
| 1090 ex = e; | |
| 1091 } | |
| 1092 assertInstanceof(ex, TypeError); | |
| 1093 assertEquals('Cannot redefine property: ownReadonlyAccessor', ex.message); | |
| 979 assertEquals(15, this.ownReadonlyAccessor); | 1094 assertEquals(15, this.ownReadonlyAccessor); |
| 980 | 1095 |
| 981 setterCalled = 0; | 1096 ex = null; |
| 982 super.ownSetter = 42; | 1097 try { |
| 983 assertEquals(1, setterCalled); | 1098 super.ownSetter = 35; |
| 1099 } catch (e) { | |
| 1100 ex = e; | |
| 1101 } | |
| 1102 assertInstanceof(ex, TypeError); | |
| 1103 assertEquals('Cannot redefine property: ownSetter', ex.message); | |
| 984 }, | 1104 }, |
| 985 mStrict() { | 1105 mStrict() { |
| 986 'use strict'; | 1106 'use strict'; |
| 1107 var ex; | |
| 987 assertEquals(42, this.ownReadOnly); | 1108 assertEquals(42, this.ownReadOnly); |
| 988 var ex; | |
| 989 try { | 1109 try { |
| 990 super.ownReadOnly = 55; | 1110 super.ownReadOnly = 55; |
| 991 } catch(e) { ex = e; } | 1111 } catch (e) { |
| 992 assertTrue(ex instanceof TypeError); | 1112 ex = e; |
| 1113 } | |
| 1114 assertInstanceof(ex, TypeError); | |
| 1115 assertEquals( | |
| 1116 'Cannot assign to read only property \'ownReadOnly\' of #<Base>', | |
| 1117 ex.message); | |
| 993 assertEquals(42, this.ownReadOnly); | 1118 assertEquals(42, this.ownReadOnly); |
| 994 | 1119 |
| 1120 ex = null; | |
| 995 assertEquals(15, this.ownReadonlyAccessor); | 1121 assertEquals(15, this.ownReadonlyAccessor); |
| 1122 try { | |
| 1123 super.ownReadonlyAccessor = 25; | |
| 1124 } catch (e) { | |
| 1125 ex = e; | |
| 1126 } | |
| 1127 assertInstanceof(ex, TypeError); | |
| 1128 assertEquals('Cannot redefine property: ownReadonlyAccessor', ex.message); | |
| 1129 assertEquals(15, this.ownReadonlyAccessor); | |
| 1130 | |
| 996 ex = null; | 1131 ex = null; |
| 997 try { | 1132 try { |
| 998 super.ownReadonlyAccessor = 55; | 1133 super.ownSetter = 35; |
| 999 } catch(e) { ex = e; } | 1134 } catch (e) { |
| 1000 assertTrue(ex instanceof TypeError); | 1135 ex = e; |
| 1001 assertEquals(15, this.ownReadonlyAccessor); | 1136 } |
| 1002 | 1137 assertInstanceof(ex, TypeError); |
| 1003 setterCalled = 0; | 1138 assertEquals('Cannot redefine property: ownSetter', ex.message); |
| 1004 super.ownSetter = 42; | |
| 1005 assertEquals(1, setterCalled); | |
| 1006 } | 1139 } |
| 1007 }; | 1140 }; |
| 1008 | 1141 |
| 1009 var d = new Derived(); | 1142 var d = new Derived(); |
| 1010 Object.defineProperty(d, 'ownReadOnly', { value : 42, writable : false }); | 1143 Object.defineProperty(d, 'ownReadOnly', { value : 42, writable : false }); |
| 1011 Object.defineProperty(d, 'ownSetter', | 1144 Object.defineProperty(d, 'ownSetter', |
| 1012 { set : function() { setterCalled++; } }); | 1145 { set : function() { assertUnreachable(); } }); |
| 1013 Object.defineProperty(d, 'ownReadonlyAccessor', | 1146 Object.defineProperty(d, 'ownReadonlyAccessor', |
| 1014 { get : function() { return 15; }}); | 1147 { get : function() { return 15; }}); |
| 1015 d.mSloppy(); | 1148 d.mSloppy(); |
| 1016 d.mStrict(); | 1149 d.mStrict(); |
| 1017 }()); | 1150 }()); |
| 1018 | 1151 |
| 1019 | 1152 |
| 1020 (function TestSetterInForIn() { | 1153 (function TestSetterInForIn() { |
| 1021 var setCalled = 0; | 1154 var setCalled = 0; |
| 1022 var getCalled = 0; | 1155 var getCalled = 0; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1069 }; | 1202 }; |
| 1070 | 1203 |
| 1071 new Derived().testIter(); | 1204 new Derived().testIter(); |
| 1072 | 1205 |
| 1073 var x = 'x'; | 1206 var x = 'x'; |
| 1074 | 1207 |
| 1075 new Derived().testIterKeyed(); | 1208 new Derived().testIterKeyed(); |
| 1076 }()); | 1209 }()); |
| 1077 | 1210 |
| 1078 | 1211 |
| 1079 (function TestKeyedSetterCreatingOwnProperties() { | 1212 (function TestKeyedSetterCreatingOwnPropertiesReconfigurable() { |
| 1080 var ownReadOnly = 'ownReadOnly'; | 1213 var ownReadOnly = 'ownReadOnly'; |
| 1081 var ownReadonlyAccessor = 'ownReadonlyAccessor'; | 1214 var ownReadonlyAccessor = 'ownReadonlyAccessor'; |
| 1082 var ownSetter = 'ownSetter'; | 1215 var ownSetter = 'ownSetter'; |
| 1083 var setterCalled; | 1216 |
| 1084 function Base() {} | 1217 function Base() {} |
| 1085 function Derived() {} | 1218 function Derived() {} |
| 1086 Derived.prototype = { | 1219 Derived.prototype = { |
| 1087 __proto__: Base.prototype, | 1220 __proto__: Base.prototype, |
| 1088 mSloppy() { | 1221 mSloppy() { |
| 1089 assertEquals(42, this[ownReadOnly]); | 1222 assertEquals(42, this[ownReadOnly]); |
| 1090 super[ownReadOnly] = 55; | 1223 super[ownReadOnly] = 55; |
| 1091 assertEquals(42, this[ownReadOnly]); | 1224 assertEquals(55, this[ownReadOnly]); |
| 1225 var descr = Object.getOwnPropertyDescriptor(this, ownReadOnly); | |
| 1226 assertEquals(55, descr.value); | |
| 1227 assertTrue(descr.configurable); | |
| 1228 assertFalse(descr.enumerable); | |
| 1229 assertFalse(descr.writable); | |
| 1230 assertFalse(Base.prototype.hasOwnProperty(ownReadOnly)); | |
| 1092 | 1231 |
| 1093 assertEquals(15, this[ownReadonlyAccessor]); | 1232 assertEquals(15, this[ownReadonlyAccessor]); |
| 1094 super[ownReadonlyAccessor] = 55; | 1233 super[ownReadonlyAccessor] = 25; |
| 1095 assertEquals(15, this[ownReadonlyAccessor]); | 1234 assertEquals(25, this[ownReadonlyAccessor]); |
| 1235 var descr = Object.getOwnPropertyDescriptor(this, ownReadonlyAccessor); | |
| 1236 assertEquals(25, descr.value); | |
| 1237 assertTrue(descr.configurable); | |
| 1238 assertFalse(descr.enumerable); | |
| 1239 assertTrue(descr.writable); | |
| 1240 assertFalse(Base.prototype.hasOwnProperty(ownReadonlyAccessor)); | |
| 1096 | 1241 |
| 1097 setterCalled = 0; | 1242 super[ownSetter] = 35; |
| 1098 super[ownSetter] = 42; | 1243 assertEquals(35, this[ownSetter]); |
| 1099 assertEquals(1, setterCalled); | 1244 var descr = Object.getOwnPropertyDescriptor(this, ownSetter); |
| 1245 assertEquals(35, descr.value); | |
| 1246 assertTrue(descr.configurable); | |
| 1247 assertFalse(descr.enumerable); | |
| 1248 assertTrue(descr.writable); | |
| 1249 assertFalse(Base.prototype.hasOwnProperty(ownSetter)); | |
| 1100 }, | 1250 }, |
| 1101 mStrict() { | 1251 mStrict() { |
| 1102 'use strict'; | 1252 'use strict'; |
| 1103 assertEquals(42, this[ownReadOnly]); | 1253 assertEquals(42, this[ownReadOnly]); |
| 1104 var ex; | 1254 super[ownReadOnly] = 55; |
| 1105 try { | 1255 assertEquals(55, this[ownReadOnly]); |
| 1106 super[ownReadOnly] = 55; | 1256 var descr = Object.getOwnPropertyDescriptor(this, ownReadOnly); |
| 1107 } catch(e) { ex = e; } | 1257 assertEquals(55, descr.value); |
| 1108 assertTrue(ex instanceof TypeError); | 1258 assertTrue(descr.configurable); |
| 1109 assertEquals(42, this[ownReadOnly]); | 1259 assertFalse(descr.enumerable); |
| 1260 assertFalse(descr.writable); | |
| 1261 assertFalse(Base.prototype.hasOwnProperty(ownReadOnly)); | |
| 1110 | 1262 |
| 1111 assertEquals(15, this[ownReadonlyAccessor]); | 1263 assertEquals(15, this[ownReadonlyAccessor]); |
| 1112 ex = null; | 1264 super[ownReadonlyAccessor] = 25; |
| 1113 try { | 1265 assertEquals(25, this[ownReadonlyAccessor]); |
| 1114 super[ownReadonlyAccessor] = 55; | 1266 var descr = Object.getOwnPropertyDescriptor(this, 'ownReadonlyAccessor'); |
| 1115 } catch(e) { ex = e; } | 1267 assertEquals(25, descr.value); |
| 1116 assertTrue(ex instanceof TypeError); | 1268 assertTrue(descr.configurable); |
| 1117 assertEquals(15, this[ownReadonlyAccessor]); | 1269 assertFalse(descr.enumerable); |
| 1270 assertTrue(descr.writable); | |
| 1271 assertFalse(Base.prototype.hasOwnProperty('ownReadonlyAccessor')); | |
| 1118 | 1272 |
| 1119 setterCalled = 0; | 1273 super[ownSetter] = 35; |
| 1120 super[ownSetter] = 42; | 1274 assertEquals(35, this[ownSetter]); |
| 1121 assertEquals(1, setterCalled); | 1275 var descr = Object.getOwnPropertyDescriptor(this, ownSetter); |
| 1122 } | 1276 assertEquals(35, descr.value); |
| 1277 assertTrue(descr.configurable); | |
| 1278 assertFalse(descr.enumerable); | |
| 1279 assertTrue(descr.writable); | |
| 1280 assertFalse(Base.prototype.hasOwnProperty(ownSetter)); | |
| 1281 }, | |
| 1123 }; | 1282 }; |
| 1124 | 1283 |
| 1125 var d = new Derived(); | 1284 var d = new Derived(); |
| 1126 Object.defineProperty(d, 'ownReadOnly', { value : 42, writable : false }); | 1285 Object.defineProperty(d, ownReadOnly, { |
| 1127 Object.defineProperty(d, 'ownSetter', | 1286 value: 42, |
| 1128 { set : function() { setterCalled++; } }); | 1287 writable: false, |
| 1129 Object.defineProperty(d, 'ownReadonlyAccessor', | 1288 configurable: true |
| 1130 { get : function() { return 15; }}); | 1289 }); |
| 1290 Object.defineProperty(d, ownSetter, { | |
| 1291 set: function() { assertUnreachable(); }, | |
| 1292 configurable: true | |
| 1293 }); | |
| 1294 Object.defineProperty(d, ownReadonlyAccessor, { | |
| 1295 get: function() { return 15; }, | |
| 1296 configurable: true | |
| 1297 }); | |
| 1298 | |
| 1131 d.mSloppy(); | 1299 d.mSloppy(); |
| 1300 | |
| 1301 var d = new Derived(); | |
| 1302 Object.defineProperty(d, ownReadOnly, { | |
| 1303 value: 42, | |
| 1304 writable: false, | |
| 1305 configurable: true | |
| 1306 }); | |
| 1307 Object.defineProperty(d, ownSetter, { | |
| 1308 set: function() { assertUnreachable(); }, | |
| 1309 configurable: true | |
| 1310 }); | |
| 1311 Object.defineProperty(d, ownReadonlyAccessor, { | |
| 1312 get: function() { return 15; }, | |
| 1313 configurable: true | |
| 1314 }); | |
| 1132 d.mStrict(); | 1315 d.mStrict(); |
| 1133 }()); | 1316 })(); |
| 1134 | 1317 |
| 1135 | 1318 |
| 1136 (function TestKeyedNumericSetterCreatingOwnProperties() { | 1319 (function TestKeyedSetterCreatingOwnPropertiesNonConfigurable() { |
| 1137 var ownReadOnly = 42; | 1320 var ownReadOnly = 'ownReadOnly'; |
| 1138 var ownReadonlyAccessor = 43; | 1321 var ownReadonlyAccessor = 'ownReadonlyAccessor'; |
| 1139 var ownSetter = 44; | 1322 var ownSetter = 'ownSetter'; |
| 1140 var setterCalled; | 1323 var setterCalled; |
| 1324 | |
| 1141 function Base() {} | 1325 function Base() {} |
| 1142 function Derived() {} | 1326 function Derived() {} |
| 1143 Derived.prototype = { | 1327 Derived.prototype = { |
| 1144 __proto__: Base.prototype, | 1328 __proto__: Base.prototype, |
| 1145 mSloppy() { | 1329 mSloppy() { |
| 1146 assertEquals(42, this[ownReadOnly]); | 1330 assertEquals(42, this[ownReadOnly]); |
| 1147 super[ownReadOnly] = 55; | 1331 super[ownReadOnly] = 55; |
| 1148 assertEquals(42, this[ownReadOnly]); | 1332 assertEquals(42, this[ownReadOnly]); |
| 1333 var descr = Object.getOwnPropertyDescriptor(this, ownReadOnly); | |
| 1334 assertEquals(42, descr.value); | |
| 1335 assertFalse(descr.configurable); | |
| 1336 assertFalse(descr.enumerable); | |
| 1337 assertFalse(descr.writable); | |
| 1338 assertFalse(Base.prototype.hasOwnProperty(ownReadOnly)); | |
| 1149 | 1339 |
| 1340 var ex; | |
| 1150 assertEquals(15, this[ownReadonlyAccessor]); | 1341 assertEquals(15, this[ownReadonlyAccessor]); |
| 1151 super[ownReadonlyAccessor] = 55; | 1342 try { |
| 1343 super[ownReadonlyAccessor] = 25; | |
| 1344 } catch (e) { | |
| 1345 ex = e; | |
| 1346 } | |
| 1347 assertInstanceof(ex, TypeError); | |
| 1348 assertEquals('Cannot redefine property: ownReadonlyAccessor', ex.message); | |
| 1152 assertEquals(15, this[ownReadonlyAccessor]); | 1349 assertEquals(15, this[ownReadonlyAccessor]); |
| 1153 | 1350 |
| 1154 setterCalled = 0; | 1351 setterCalled = 0; |
| 1155 super[ownSetter] = 42; | 1352 ex = null; |
| 1156 assertEquals(1, setterCalled); | 1353 try { |
| 1354 super[ownSetter] = 35; | |
| 1355 } catch (e) { | |
| 1356 ex = e; | |
| 1357 } | |
| 1358 assertInstanceof(ex, TypeError); | |
| 1359 assertEquals('Cannot redefine property: ownSetter', ex.message); | |
| 1360 assertEquals(0, setterCalled); | |
| 1157 }, | 1361 }, |
| 1158 mStrict() { | 1362 mStrict() { |
| 1159 'use strict'; | 1363 'use strict'; |
| 1160 assertEquals(42, this[ownReadOnly]); | |
| 1161 var ex; | 1364 var ex; |
| 1365 assertEquals(42, this.ownReadOnly); | |
| 1162 try { | 1366 try { |
| 1163 super[ownReadOnly] = 55; | 1367 super.ownReadOnly = 55; |
| 1164 } catch(e) { ex = e; } | 1368 } catch (e) { |
| 1165 assertTrue(ex instanceof TypeError); | 1369 ex = e; |
| 1166 assertEquals(42, this[ownReadOnly]); | 1370 } |
| 1371 assertInstanceof(ex, TypeError); | |
| 1372 assertEquals( | |
| 1373 'Cannot assign to read only property \'ownReadOnly\' of #<Base>', | |
| 1374 ex.message); | |
| 1375 assertEquals(42, this.ownReadOnly); | |
| 1167 | 1376 |
| 1377 ex = null; | |
| 1168 assertEquals(15, this[ownReadonlyAccessor]); | 1378 assertEquals(15, this[ownReadonlyAccessor]); |
| 1169 ex = null; | |
| 1170 try { | 1379 try { |
| 1171 super[ownReadonlyAccessor] = 55; | 1380 super[ownReadonlyAccessor] = 25; |
| 1172 } catch(e) { ex = e; } | 1381 } catch (e) { |
| 1173 assertTrue(ex instanceof TypeError); | 1382 ex = e; |
| 1383 } | |
| 1384 assertInstanceof(ex, TypeError); | |
| 1385 assertEquals('Cannot redefine property: ownReadonlyAccessor', ex.message); | |
| 1174 assertEquals(15, this[ownReadonlyAccessor]); | 1386 assertEquals(15, this[ownReadonlyAccessor]); |
| 1175 | 1387 |
| 1176 setterCalled = 0; | 1388 setterCalled = 0; |
| 1177 super[ownSetter] = 42; | 1389 ex = null; |
| 1178 assertEquals(1, setterCalled); | 1390 try { |
| 1391 super[ownSetter] = 35; | |
| 1392 } catch (e) { | |
| 1393 ex = e; | |
| 1394 } | |
| 1395 assertInstanceof(ex, TypeError); | |
| 1396 assertEquals('Cannot redefine property: ownSetter', ex.message); | |
| 1397 assertEquals(0, setterCalled); | |
| 1179 } | 1398 } |
| 1180 } | 1399 }; |
| 1181 | 1400 |
| 1182 var d = new Derived(); | 1401 var d = new Derived(); |
| 1183 Object.defineProperty(d, ownReadOnly, { value : 42, writable : false }); | 1402 Object.defineProperty(d, 'ownReadOnly', { value : 42, writable : false }); |
| 1184 Object.defineProperty(d, ownSetter, | 1403 Object.defineProperty(d, 'ownSetter', |
| 1185 { set : function() { setterCalled++; } }); | 1404 { set : function() { setterCalled++; } }); |
| 1186 Object.defineProperty(d, ownReadonlyAccessor, | 1405 Object.defineProperty(d, 'ownReadonlyAccessor', |
| 1187 { get : function() { return 15; }}); | 1406 { get : function() { return 15; }}); |
| 1188 d.mSloppy(); | 1407 d.mSloppy(); |
| 1189 d.mStrict(); | 1408 d.mStrict(); |
| 1409 | |
| 1190 }()); | 1410 }()); |
| 1191 | 1411 |
| 1192 | 1412 |
| 1413 // TODO(arv): This is broken | |
|
arv (Not doing code reviews)
2015/02/17 20:41:22
The runtime calls SetElementWithInterceptor. It do
| |
| 1414 // (function TestKeyedNumericSetterCreatingOwnProperties() { | |
| 1415 // var ownReadOnly = 42; | |
| 1416 // var ownReadonlyAccessor = 43; | |
| 1417 // var ownSetter = 44; | |
| 1418 // var setterCalled; | |
| 1419 | |
| 1420 // function Base() {} | |
| 1421 // function Derived() {} | |
| 1422 // Derived.prototype = { | |
| 1423 // __proto__: Base.prototype, | |
| 1424 // mSloppy() { | |
| 1425 // assertEquals(42, this[ownReadOnly]); | |
| 1426 // super[ownReadOnly] = 55; | |
| 1427 // assertEquals(42, this[ownReadOnly]); | |
| 1428 | |
| 1429 // var ex; | |
| 1430 // assertEquals(15, this[ownReadonlyAccessor]); | |
| 1431 // try { | |
| 1432 // super[ownReadonlyAccessor] = 55; | |
| 1433 // } catch (e) { | |
| 1434 // ex = e; | |
| 1435 // } | |
| 1436 // assertInstanceof(ex, TypeError); | |
| 1437 // assertEquals('Cannot redefine property: 43', ex.message); | |
| 1438 // assertEquals(15, this[ownReadonlyAccessor]); | |
| 1439 | |
| 1440 // // setterCalled = 0; | |
| 1441 // // super[ownSetter] = 42; | |
| 1442 // // assertEquals(1, setterCalled); | |
| 1443 // }, | |
| 1444 // mStrict() { | |
| 1445 // // 'use strict'; | |
| 1446 // // assertEquals(42, this[ownReadOnly]); | |
| 1447 // // var ex; | |
| 1448 // // try { | |
| 1449 // // super[ownReadOnly] = 55; | |
| 1450 // // } catch(e) { ex = e; } | |
| 1451 // // assertInstanceof(ex, TypeError); | |
| 1452 // // assertEquals(42, this[ownReadOnly]); | |
| 1453 | |
| 1454 // // assertEquals(15, this[ownReadonlyAccessor]); | |
| 1455 // // ex = null; | |
| 1456 // // try { | |
| 1457 // // super[ownReadonlyAccessor] = 55; | |
| 1458 // // } catch(e) { ex = e; } | |
| 1459 // // assertInstanceof(ex, TypeError); | |
| 1460 // // assertEquals(15, this[ownReadonlyAccessor]); | |
| 1461 | |
| 1462 // // setterCalled = 0; | |
| 1463 // // super[ownSetter] = 42; | |
| 1464 // // assertEquals(1, setterCalled); | |
| 1465 // } | |
| 1466 // } | |
| 1467 | |
| 1468 // var d = new Derived(); | |
| 1469 // Object.defineProperty(d, ownReadOnly, { value : 42, writable : false }); | |
| 1470 // Object.defineProperty(d, ownSetter, | |
| 1471 // { set : function() { setterCalled++; } }); | |
| 1472 // Object.defineProperty(d, ownReadonlyAccessor, | |
| 1473 // { get : function() { return 15; }}); | |
| 1474 // d.mSloppy(); | |
| 1475 // d.mStrict(); | |
| 1476 // }()); | |
| 1477 | |
| 1478 | |
| 1193 (function TestSetterNoProtoWalk() { | 1479 (function TestSetterNoProtoWalk() { |
| 1194 function Base() {} | 1480 function Base() {} |
| 1195 function Derived() {} | 1481 function Derived() {} |
| 1196 var getCalled; | 1482 var getCalled; |
| 1197 var setCalled; | 1483 var setCalled; |
| 1198 Derived.prototype = { | 1484 Derived.prototype = { |
| 1199 __proto__: Base.prototype, | 1485 __proto__: Base.prototype, |
| 1200 get x() { getCalled++; return 42; }, | 1486 get x() { getCalled++; return 42; }, |
| 1201 set x(v) { setCalled++; }, | 1487 set x(v) { setCalled++; }, |
| 1202 mSloppy() { | 1488 mSloppy() { |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1677 super.x = 10; | 1963 super.x = 10; |
| 1678 assertEquals(27, super.x); | 1964 assertEquals(27, super.x); |
| 1679 assertEquals(27, this.x); | 1965 assertEquals(27, this.x); |
| 1680 }, | 1966 }, |
| 1681 mStrict() { | 1967 mStrict() { |
| 1682 'use strict'; | 1968 'use strict'; |
| 1683 assertEquals(27, super.x); | 1969 assertEquals(27, super.x); |
| 1684 assertEquals(27, this.x); | 1970 assertEquals(27, this.x); |
| 1685 var ex = null; | 1971 var ex = null; |
| 1686 try { super.x = 10; } catch(e) { ex = e; } | 1972 try { super.x = 10; } catch(e) { ex = e; } |
| 1687 assertTrue(ex instanceof TypeError); | 1973 assertInstanceof(ex, TypeError); |
| 1688 assertEquals(27, super.x); | 1974 assertEquals(27, super.x); |
| 1689 assertEquals(27, this.x); | 1975 assertEquals(27, this.x); |
| 1690 } | 1976 } |
| 1691 }; | 1977 }; |
| 1692 new Derived().mSloppy(); | 1978 new Derived().mSloppy(); |
| 1693 new Derived().mStrict(); | 1979 new Derived().mStrict(); |
| 1694 }()); | 1980 }()); |
| 1695 | 1981 |
| 1696 | 1982 |
| 1697 (function TestSetterKeyedSuperNonWritable() { | 1983 (function TestSetterKeyedSuperNonWritable() { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1709 super[x] = 10; | 1995 super[x] = 10; |
| 1710 assertEquals(27, super[x]); | 1996 assertEquals(27, super[x]); |
| 1711 assertEquals(27, this[x]); | 1997 assertEquals(27, this[x]); |
| 1712 }, | 1998 }, |
| 1713 mStrict() { | 1999 mStrict() { |
| 1714 'use strict'; | 2000 'use strict'; |
| 1715 assertEquals(27, super[x]); | 2001 assertEquals(27, super[x]); |
| 1716 assertEquals(27, this[x]); | 2002 assertEquals(27, this[x]); |
| 1717 var ex = null; | 2003 var ex = null; |
| 1718 try { super[x] = 10; } catch(e) { ex = e; } | 2004 try { super[x] = 10; } catch(e) { ex = e; } |
| 1719 assertTrue(ex instanceof TypeError); | 2005 assertInstanceof(ex, TypeError); |
| 1720 assertEquals(27, super[x]); | 2006 assertEquals(27, super[x]); |
| 1721 assertEquals(27, this[x]); | 2007 assertEquals(27, this[x]); |
| 1722 } | 2008 } |
| 1723 }; | 2009 }; |
| 1724 new Derived().mSloppy(); | 2010 new Derived().mSloppy(); |
| 1725 new Derived().mStrict(); | 2011 new Derived().mStrict(); |
| 1726 }()); | 2012 }()); |
| 1727 | 2013 |
| 1728 | 2014 |
| 1729 (function TestSetterKeyedNumericSuperNonWritable() { | 2015 (function TestSetterKeyedNumericSuperNonWritable() { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1741 super[x] = 10; | 2027 super[x] = 10; |
| 1742 assertEquals(27, super[x]); | 2028 assertEquals(27, super[x]); |
| 1743 assertEquals(27, this[x]); | 2029 assertEquals(27, this[x]); |
| 1744 }, | 2030 }, |
| 1745 mStrict() { | 2031 mStrict() { |
| 1746 'use strict'; | 2032 'use strict'; |
| 1747 assertEquals(27, super[x]); | 2033 assertEquals(27, super[x]); |
| 1748 assertEquals(27, this[x]); | 2034 assertEquals(27, this[x]); |
| 1749 var ex = null; | 2035 var ex = null; |
| 1750 try { super[x] = 10; } catch(e) { ex = e; } | 2036 try { super[x] = 10; } catch(e) { ex = e; } |
| 1751 assertTrue(ex instanceof TypeError); | 2037 assertInstanceof(ex, TypeError); |
| 1752 assertEquals(27, super[x]); | 2038 assertEquals(27, super[x]); |
| 1753 assertEquals(27, this[x]); | 2039 assertEquals(27, this[x]); |
| 1754 } | 2040 } |
| 1755 }; | 2041 }; |
| 1756 new Derived().mSloppy(); | 2042 new Derived().mSloppy(); |
| 1757 new Derived().mStrict(); | 2043 new Derived().mStrict(); |
| 1758 }()); | 2044 }()); |
| 1759 | 2045 |
| 1760 | 2046 |
| 1761 (function TestSuperCall() { | 2047 (function TestSuperCall() { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1838 assertEquals(1, calls); | 2124 assertEquals(1, calls); |
| 1839 }()); | 2125 }()); |
| 1840 | 2126 |
| 1841 | 2127 |
| 1842 (function TestExtendsObject() { | 2128 (function TestExtendsObject() { |
| 1843 'use strict'; | 2129 'use strict'; |
| 1844 class F extends Object { } | 2130 class F extends Object { } |
| 1845 var f = new F(42); | 2131 var f = new F(42); |
| 1846 | 2132 |
| 1847 // TODO(dslomov,arv): Fix this. BUG=v8:3886. | 2133 // TODO(dslomov,arv): Fix this. BUG=v8:3886. |
| 1848 assertTrue(f instanceof Number); | 2134 assertInstanceof(f, Number); |
| 1849 }()); | 2135 }()); |
| 1850 | 2136 |
| 1851 (function TestSuperCallErrorCases() { | 2137 (function TestSuperCallErrorCases() { |
| 1852 'use strict'; | 2138 'use strict'; |
| 1853 class T extends Object { | 2139 class T extends Object { |
| 1854 constructor() { | 2140 constructor() { |
| 1855 super(); | 2141 super(); |
| 1856 } | 2142 } |
| 1857 } | 2143 } |
| 1858 | 2144 |
| 1859 T.__proto__ = null; | 2145 T.__proto__ = null; |
| 1860 assertThrows(function() { new T(); }, TypeError); | 2146 assertThrows(function() { new T(); }, TypeError); |
| 1861 }()); | 2147 }()); |
| OLD | NEW |