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-bind | 5 // Flags: --harmony-destructuring-bind |
6 // Flags: --harmony-default-parameters | 6 // Flags: --harmony-default-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 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 function f6(x, ...a) { x = 2; return arguments[0] } | 1054 function f6(x, ...a) { x = 2; return arguments[0] } |
1055 assertEquals(6, f6(6, {})); | 1055 assertEquals(6, f6(6, {})); |
1056 function f7({a: x}) { x = 2; return arguments[0].a } | 1056 function f7({a: x}) { x = 2; return arguments[0].a } |
1057 assertEquals(5, f7({a: 5})); | 1057 assertEquals(5, f7({a: 5})); |
1058 function f8(x, ...a) { a = []; return arguments[1] } | 1058 function f8(x, ...a) { a = []; return arguments[1] } |
1059 assertEquals(6, f8(5, 6)); | 1059 assertEquals(6, f8(5, 6)); |
1060 }()); | 1060 }()); |
1061 | 1061 |
1062 | 1062 |
1063 (function TestForInOfTDZ() { | 1063 (function TestForInOfTDZ() { |
1064 assertThrows("'use strict'; let x = {}; for (let [x, y] of {x});", ReferenceEr
ror); | 1064 assertThrows("'use strict'; let x = {}; for (let [x, y] of [x]);", ReferenceEr
ror); |
1065 assertThrows("'use strict'; let x = {}; for (let [y, x] of {x});", ReferenceEr
ror); | 1065 assertThrows("'use strict'; let x = {}; for (let [y, x] of [x]);", ReferenceEr
ror); |
1066 assertThrows("'use strict'; let x = {}; for (let [x, y] in {x});", ReferenceEr
ror); | 1066 assertThrows("'use strict'; let x = {}; for (let [x, y] in {x});", ReferenceEr
ror); |
1067 assertThrows("'use strict'; let x = {}; for (let [y, x] in {x});", ReferenceEr
ror); | 1067 assertThrows("'use strict'; let x = {}; for (let [y, x] in {x});", ReferenceEr
ror); |
1068 }()); | 1068 }()); |
1069 | 1069 |
1070 | 1070 |
1071 (function TestFunctionLength() { | 1071 (function TestFunctionLength() { |
1072 assertEquals(1, (function({}) {}).length); | 1072 assertEquals(1, (function({}) {}).length); |
1073 assertEquals(1, (function([]) {}).length); | 1073 assertEquals(1, (function([]) {}).length); |
1074 assertEquals(1, (function({x}) {}).length); | 1074 assertEquals(1, (function({x}) {}).length); |
1075 assertEquals(1, (function({}, ...a) {}).length); | 1075 assertEquals(1, (function({}, ...a) {}).length); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 throw [1, 2, 3]; | 1125 throw [1, 2, 3]; |
1126 } catch ([foo, ...bar]) { | 1126 } catch ([foo, ...bar]) { |
1127 assertEquals(1, foo); | 1127 assertEquals(1, foo); |
1128 assertEquals([2, 3], bar); | 1128 assertEquals([2, 3], bar); |
1129 } | 1129 } |
1130 | 1130 |
1131 assertEquals("hello", foo); | 1131 assertEquals("hello", foo); |
1132 assertEquals("world", bar); | 1132 assertEquals("world", bar); |
1133 assertEquals(42, baz); | 1133 assertEquals(42, baz); |
1134 })(); | 1134 })(); |
OLD | NEW |