Chromium Code Reviews| Index: test/mjsunit/harmony/destructuring.js |
| diff --git a/test/mjsunit/harmony/destructuring.js b/test/mjsunit/harmony/destructuring.js |
| index 3e1726fdc2d6ab99b152548c32f401b2701a6072..6e386efa0d024aab6e38c9e643fe1a9855e2f4a5 100644 |
| --- a/test/mjsunit/harmony/destructuring.js |
| +++ b/test/mjsunit/harmony/destructuring.js |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| // |
| -// Flags: --harmony-destructuring |
| +// Flags: --harmony-destructuring --harmony-computed-property-names |
| (function TestObjectLiteralPattern() { |
| var { x : x, y : y } = { x : 1, y : 2 }; |
| @@ -283,6 +283,67 @@ |
| }()); |
| +(function TestComputedNames() { |
|
rossberg
2015/05/19 11:50:34
Add tests with computed accessor and method names.
Dmitry Lomov (no reviews)
2015/05/19 14:07:28
Uhm, accessors and method names are not allowed in
|
| + var x = 1; |
| + var {[x]:y} = {1:2}; |
| + assertSame(2, y); |
| + |
| + (function(){ |
| + 'use strict'; |
| + let {[x]:y} = {1:2}; |
| + assertSame(2, y); |
| + }()); |
| + |
| + var callCount = 0; |
| + function foo(v) { callCount++; return v; } |
| + |
| + (function() { |
| + callCount = 0; |
| + var {[foo("abc")]:x} = {abc:42}; |
| + assertSame(42, x); |
| + assertEquals(1, callCount); |
| + }()); |
| + |
| + (function() { |
| + 'use strict'; |
| + callCount = 0; |
| + let {[foo("abc")]:x} = {abc:42}; |
| + assertSame(42, x); |
| + assertEquals(1, callCount); |
| + }()); |
| + |
| + (function() { |
| + callCount = 0; |
| + var {[foo("abc")]:x} = {}; |
| + assertSame(undefined, x); |
| + assertEquals(1, callCount); |
| + }()); |
| + |
| + (function() { |
| + 'use strict'; |
| + callCount = 0; |
| + let {[foo("abc")]:x} = {}; |
| + assertSame(undefined, x); |
| + assertEquals(1, callCount); |
| + }()); |
| + |
| + for (val of [null, undefined]) { |
| + callCount = 0; |
| + assertThrows(function() { |
| + var {[foo()]:x} = val; |
| + }, TypeError); |
| + assertEquals(0, callCount); |
| + |
| + callCount = 0; |
| + assertThrows(function() { |
| + 'use strict'; |
| + let {[foo()]:x} = val; |
| + }, TypeError); |
| + assertEquals(0, callCount); |
| + } |
| +}()); |
|
arv (Not doing code reviews)
2015/05/19 14:19:56
Can haz order tests?
var log = [];
var obj = {
Dmitry Lomov (no reviews)
2015/05/19 14:52:00
Done.
|
| + |
| + |
| (function TestExceptions() { |
| for (var val of [null, undefined]) { |
| assertThrows(function() { var {} = val; }, TypeError); |