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

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

Issue 1411203002: [es6] implement destructuring assignment [clean diff] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Completion-value reusing that may not necessarily accomplish anything Created 5 years, 2 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
« src/pattern-rewriter.cc ('K') | « src/pattern-rewriter.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-assignment.js
diff --git a/test/mjsunit/harmony/destructuring-assignment.js b/test/mjsunit/harmony/destructuring-assignment.js
new file mode 100644
index 0000000000000000000000000000000000000000..8c51b45216bfa0b8f626dc4645d7c3d355bf2cb2
--- /dev/null
+++ b/test/mjsunit/harmony/destructuring-assignment.js
@@ -0,0 +1,54 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-destructuring-assignment --harmony-sloppy
+//
+
+function TestBasics() {
+ var a = {}, b, c, value = { a: "alpha", b: "beta", c: "gamma" };
+ assertEquals({a: a.str1} = {b: a.str2} = {c: a.str3} = {b, c} = value, value);
+ assertEquals(a, {str1: "alpha", str2: "beta", str3: "gamma"});
+ assertEquals(b, "beta");
+ assertEquals(c, "gamma");
+
+ assertEquals([a.str1, ,...c] = [, b] = "☕✌♥♫♪★", "☕✌♥♫♪★");
+ assertEquals(a.str1, "☕");
+ assertEquals(b, "✌");
+ assertEquals(c, ["♥", "♫", "♪", "★"]);
+
+ // Super-properties used
+ var bs = {};
+ class SuperClass {
+ get verbose() { return bs.verbose; }
+ set verbose(v) { bs.verboseSet = true; bs.verbose = v; }
+ get warningsAsErrors() { return bs.warningsAsErrors; }
+ set warningsAsErrors(v) {
+ bs.warningsAsErrorsSet = true;
+ bs.warningsAsErrors = v;
+ }
+ get entries() { return bs.entries; }
+ set entries(v) { bs.entriesSet = true; bs.entries = v; }
+ }
+ class ChildClass extends SuperClass {
+ constructor(O) {
+ super();
+ ({
+ verbose: super.verbose = false,
+ warningsAsErrors: super.warningsAsErrors = false,
+ entries: [...super.entries]
+ } = O || { entries: [] });
+ }
+ };
+ var childClass = new ChildClass({
+ warningsAsErrors: true,
+ entries: [1, 2, 3]
+ });
+ assertEquals(childClass.verbose, false);
+ assertEquals(childClass.warningsAsErrors, true);
+ assertEquals(childClass.entries, [1, 2, 3]);
+ assertEquals({ verboseSet: true, verbose: false,
+ warningsAsErrorsSet: true, warningsAsErrors: true,
+ entriesSet: true, entries: [1, 2, 3] }, bs);
+}
+TestBasics();
« src/pattern-rewriter.cc ('K') | « src/pattern-rewriter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698