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 --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 = { |
11 f() { | 11 f() { |
12 return "Base " + this.toString(); | 12 return "Base " + this.toString(); |
13 }, | 13 }, |
14 x: 15, | 14 x: 15, |
15 toString() { | 15 toString() { |
(...skipping 17 matching lines...) Expand all Loading... |
33 return "Derived"; | 33 return "Derived"; |
34 } | 34 } |
35 }; | 35 }; |
36 | 36 |
37 assertEquals("Base this is Base", new Base().f()); | 37 assertEquals("Base this is Base", new Base().f()); |
38 assertEquals("Derived", new Derived().f()); | 38 assertEquals("Derived", new Derived().f()); |
39 }()); | 39 }()); |
40 | 40 |
41 | 41 |
42 (function TestSuperKeyedLoads() { | 42 (function TestSuperKeyedLoads() { |
| 43 'use strict'; |
| 44 |
43 var x = 'x'; | 45 var x = 'x'; |
44 var derivedDataProperty = 'derivedDataProperty'; | 46 var derivedDataProperty = 'derivedDataProperty'; |
45 var f = 'f'; | 47 var f = 'f'; |
46 | 48 |
47 function Base() { } | 49 class Base { |
48 function fBase() { return "Base " + this.toString(); } | 50 f() { |
49 Base.prototype[f] = fBase.toMethod(Base.prototype); | 51 return "Base " + this.toString(); |
| 52 } |
| 53 toString() { |
| 54 return "this is Base"; |
| 55 } |
| 56 } |
| 57 |
50 Base.prototype[x] = 15; | 58 Base.prototype[x] = 15; |
51 Base.prototype.toString = function() { return "this is Base"; }; | |
52 | 59 |
53 function Derived() { | 60 function Derived() { |
54 this[derivedDataProperty] = "xxx"; | 61 this[derivedDataProperty] = "xxx"; |
55 } | 62 } |
56 Derived.prototype = { | 63 Derived.prototype = { |
57 __proto__: Base.prototype, | 64 __proto__: Base.prototype, |
58 toString() { return "this is Derived"; }, | 65 toString() { return "this is Derived"; }, |
59 x: 27, | 66 x: 27, |
60 f() { | 67 f() { |
61 assertEquals("Base this is Derived", super[f]()); | 68 assertEquals("Base this is Derived", super[f]()); |
(...skipping 10 matching lines...) Expand all Loading... |
72 }()); | 79 }()); |
73 | 80 |
74 | 81 |
75 (function TestSuperNumericKeyedLoads() { | 82 (function TestSuperNumericKeyedLoads() { |
76 var x = 1; | 83 var x = 1; |
77 var derivedDataProperty = 2; | 84 var derivedDataProperty = 2; |
78 var f = 3; | 85 var f = 3; |
79 | 86 |
80 function Base() { } | 87 function Base() { } |
81 function fBase() { return "Base " + this.toString(); } | 88 function fBase() { return "Base " + this.toString(); } |
82 Base.prototype[f] = fBase.toMethod(Base.prototype); | 89 Base.prototype[f] = %ToMethod(fBase, Base.prototype); |
83 Base.prototype[x] = 15; | 90 Base.prototype[x] = 15; |
84 Base.prototype.toString = function() { return "this is Base"; }; | 91 Base.prototype.toString = function() { return "this is Base"; }; |
85 | 92 |
86 function Derived() { | 93 function Derived() { |
87 this[derivedDataProperty] = "xxx"; | 94 this[derivedDataProperty] = "xxx"; |
88 } | 95 } |
89 Derived.prototype = { | 96 Derived.prototype = { |
90 __proto__: Base.prototype, | 97 __proto__: Base.prototype, |
91 toString() { return "this is Derived"; }, | 98 toString() { return "this is Derived"; }, |
92 1: 27, | 99 1: 27, |
(...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1915 | 1922 |
1916 class C3 { | 1923 class C3 { |
1917 constructor() { | 1924 constructor() { |
1918 ; 'use strict';;;;; | 1925 ; 'use strict';;;;; |
1919 // This is a comment. | 1926 // This is a comment. |
1920 super(); | 1927 super(); |
1921 } | 1928 } |
1922 } | 1929 } |
1923 new C3(); | 1930 new C3(); |
1924 }()); | 1931 }()); |
OLD | NEW |