OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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-destructuring --harmony-default-parameters | 5 // Flags: --harmony-destructuring --harmony-default-parameters |
6 | 6 |
7 (function testExpressionTypes() { | 7 (function testExpressionTypes() { |
8 "use strict"; | 8 "use strict"; |
9 ((x, y = x) => assertEquals(42, y))(42); | 9 ((x, y = x) => assertEquals(42, y))(42); |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 })) => assertEquals(42, y.z))(42); | 47 })) => assertEquals(42, y.z))(42); |
48 | 48 |
49 ((x, y = (new class extends x { | 49 ((x, y = (new class extends x { |
50 })) => assertEquals(42, y.z()))(class { z() { return 42 } }); | 50 })) => assertEquals(42, y.z()))(class { z() { return 42 } }); |
51 | 51 |
52 // Defaults inside destructuring | 52 // Defaults inside destructuring |
53 ((x, {y = x}) => assertEquals(42, y))(42, {}); | 53 ((x, {y = x}) => assertEquals(42, y))(42, {}); |
54 ((x, [y = x]) => assertEquals(42, y))(42, []); | 54 ((x, [y = x]) => assertEquals(42, y))(42, []); |
55 })(); | 55 })(); |
56 | 56 |
| 57 |
57 (function testMultiScopeCapture() { | 58 (function testMultiScopeCapture() { |
58 "use strict"; | 59 "use strict"; |
59 var x = 1; | 60 var x = 1; |
60 { | 61 { |
61 let y = 2; | 62 let y = 2; |
62 ((x, y, a = x, b = y) => { | 63 ((x, y, a = x, b = y) => { |
63 assertEquals(3, x); | 64 assertEquals(3, x); |
64 assertEquals(3, a); | 65 assertEquals(3, a); |
65 assertEquals(4, y); | 66 assertEquals(4, y); |
66 assertEquals(4, b); | 67 assertEquals(4, b); |
67 })(3, 4); | 68 })(3, 4); |
68 } | 69 } |
69 })(); | 70 })(); |
| 71 |
| 72 |
| 73 (function testSuper() { |
| 74 "use strict"; |
| 75 class A { |
| 76 x() { return 42; } |
| 77 } |
| 78 |
| 79 class B extends A { |
| 80 y() { |
| 81 ((q = super.x()) => assertEquals(42, q))(); |
| 82 } |
| 83 } |
| 84 |
| 85 new B().y(); |
| 86 |
| 87 class C { |
| 88 constructor() { return { prop: 42 } } |
| 89 } |
| 90 |
| 91 class D extends C{ |
| 92 constructor() { |
| 93 ((q = super()) => assertEquals(42, q.prop))(); |
| 94 } |
| 95 } |
| 96 |
| 97 new D(); |
| 98 })(); |
OLD | NEW |