Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Unified Diff: test/mjsunit/harmony/destructuring.js

Issue 1129083009: [destructuring] Support computed property names in patterns. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Minor test fix Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698