v8/test/mjsunit/harmony/regress/regress-4696.js
nikolaos 52a01ae0c7 Fix bug with spread rewriting
It was not properly rewriting three cases:

-   [...[42]][0]
-   [...[42]].length
-   [...[42]] `foo`    (which is a type error)

R=rossberg@chromium.org
BUG=v8:4696
LOG=N

Review URL: https://codereview.chromium.org/1617713002

Cr-Commit-Position: refs/heads/master@{#33433}
2016-01-21 12:16:20 +00:00

30 lines
756 B
JavaScript

// Copyright 2016 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.
(function testSpreadIndex() {
var result = [...[17, 42]][1];
assertEquals(result, 42);
})();
(function testSpreadProperty() {
var result = [...[17, 42]].length;
assertEquals(result, 2);
})();
(function testSpreadMethodCall() {
var result = [...[17, 42]].join("+");
assertEquals(result, "17+42");
})();
(function testSpreadSavedMethodCall() {
var x = [...[17, 42]];
var method = x.join;
var result = method.call(x, "+");
assertEquals(result, "17+42");
})();
(function testSpreadAsTemplateTag() {
assertThrows(function() { [...[17, 42]] `foo`; }, TypeError)
})();