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 | 5 // Flags: --harmony-destructuring |
6 // Flags: --harmony-default-parameters --harmony-rest-parameters | 6 // Flags: --harmony-default-parameters --harmony-rest-parameters |
7 | 7 |
8 (function TestObjectLiteralPattern() { | 8 (function TestObjectLiteralPattern() { |
9 var { x : x, y : y, get, set } = { x : 1, y : 2, get: 3, set: 4 }; | 9 var { x : x, y : y, get, set } = { x : 1, y : 2, get: 3, set: 4 }; |
10 assertEquals(1, x); | 10 assertEquals(1, x); |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1100 | 1100 |
1101 (function TestLegacyConstDestructuringInForLoop() { | 1101 (function TestLegacyConstDestructuringInForLoop() { |
1102 var result; | 1102 var result; |
1103 for (const {foo} of [{foo: 1}]) { result = foo; } | 1103 for (const {foo} of [{foo: 1}]) { result = foo; } |
1104 assertEquals(1, result); | 1104 assertEquals(1, result); |
1105 })(); | 1105 })(); |
1106 | 1106 |
1107 (function TestDestructuringArrayWithoutInitializer() { | 1107 (function TestDestructuringArrayWithoutInitializer() { |
1108 assertThrows('var [foo]', TypeError); | 1108 assertThrows('var [foo]', TypeError); |
1109 })(); | 1109 })(); |
1110 | |
1111 | |
1112 (function TestCatch() { | |
1113 "use strict"; | |
1114 | |
1115 try { | |
1116 throw {foo: 1, bar: 2}; | |
1117 } catch ({foo, bar, baz = 3}) { | |
1118 assertEquals(1, foo); | |
1119 assertEquals(2, bar); | |
1120 assertEquals(3, baz); | |
1121 } | |
1122 | |
1123 try { | |
1124 throw [1, 2, 3]; | |
1125 } catch ([foo, ...bar]) { | |
1126 assertEquals(1, foo); | |
1127 assertEquals([2, 3], bar); | |
1128 } | |
1129 | |
1130 // Should be lexically scoped inside catch scopes. | |
1131 assertEquals("undefined", typeof foo); | |
rossberg
2015/11/03 12:00:50
This is not a sufficient test, because it will be
adamk
2015/11/03 20:35:20
Fixed.
Not sure how much more to test here, I'm n
rossberg
2015/11/04 10:26:56
Yeah, I think it's fine. Setting up the descriptor
| |
1132 assertEquals("undefined", typeof bar); | |
1133 assertEquals("undefined", typeof baz); | |
1134 })(); | |
OLD | NEW |