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

Side by Side 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 unified diff | Download patch
« src/pattern-rewriter.cc ('K') | « src/pattern-rewriter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --harmony-destructuring-assignment --harmony-sloppy
6 //
7
8 function TestBasics() {
9 var a = {}, b, c, value = { a: "alpha", b: "beta", c: "gamma" };
10 assertEquals({a: a.str1} = {b: a.str2} = {c: a.str3} = {b, c} = value, value);
11 assertEquals(a, {str1: "alpha", str2: "beta", str3: "gamma"});
12 assertEquals(b, "beta");
13 assertEquals(c, "gamma");
14
15 assertEquals([a.str1, ,...c] = [, b] = "☕✌♥♫♪★", "☕✌♥♫♪★");
16 assertEquals(a.str1, "☕");
17 assertEquals(b, "✌");
18 assertEquals(c, ["♥", "♫", "♪", "★"]);
19
20 // Super-properties used
21 var bs = {};
22 class SuperClass {
23 get verbose() { return bs.verbose; }
24 set verbose(v) { bs.verboseSet = true; bs.verbose = v; }
25 get warningsAsErrors() { return bs.warningsAsErrors; }
26 set warningsAsErrors(v) {
27 bs.warningsAsErrorsSet = true;
28 bs.warningsAsErrors = v;
29 }
30 get entries() { return bs.entries; }
31 set entries(v) { bs.entriesSet = true; bs.entries = v; }
32 }
33 class ChildClass extends SuperClass {
34 constructor(O) {
35 super();
36 ({
37 verbose: super.verbose = false,
38 warningsAsErrors: super.warningsAsErrors = false,
39 entries: [...super.entries]
40 } = O || { entries: [] });
41 }
42 };
43 var childClass = new ChildClass({
44 warningsAsErrors: true,
45 entries: [1, 2, 3]
46 });
47 assertEquals(childClass.verbose, false);
48 assertEquals(childClass.warningsAsErrors, true);
49 assertEquals(childClass.entries, [1, 2, 3]);
50 assertEquals({ verboseSet: true, verbose: false,
51 warningsAsErrorsSet: true, warningsAsErrors: true,
52 entriesSet: true, entries: [1, 2, 3] }, bs);
53 }
54 TestBasics();
OLDNEW
« 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