| 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();
|
|
|