diff options
author | Michaƫl Zasso <targos@protonmail.com> | 2017-09-12 11:34:59 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-09-13 16:15:18 +0200 |
commit | d82e1075dbc2cec2d6598ade10c1f43805f690fd (patch) | |
tree | ccd242b9b491dfc341d1099fe11b0ef528839877 /deps/v8/test/mjsunit/compiler/spread-call.js | |
parent | b4b7ac6ae811b2b5a3082468115dfb5a5246fe3f (diff) | |
download | node-new-d82e1075dbc2cec2d6598ade10c1f43805f690fd.tar.gz |
deps: update V8 to 6.1.534.36
PR-URL: https://github.com/nodejs/node/pull/14730
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'deps/v8/test/mjsunit/compiler/spread-call.js')
-rw-r--r-- | deps/v8/test/mjsunit/compiler/spread-call.js | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/compiler/spread-call.js b/deps/v8/test/mjsunit/compiler/spread-call.js new file mode 100644 index 0000000000..1b7ae6f301 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/spread-call.js @@ -0,0 +1,80 @@ +// 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. + +// Flags: --allow-natives-syntax + +function tests() { + "use strict" + function countArgs() { return arguments.length; } + + // Array params + assertEquals(3, countArgs(...[1, 2, 3])); // Smi + assertEquals(4, countArgs(...[1, 2, , 3])); // HoleySmi + assertEquals(3, countArgs(...[1.1, 2, 3])); // Double + assertEquals(4, countArgs(...[1.1, 2, , 3])); // HoleyDouble + assertEquals(3, countArgs(...[{valueOf: () => 0}, 1.1, '2'])); // Object + assertEquals( + 4, countArgs(...[{valueOf: () => 0}, 1.1, , '2'])); // HoleyObject + + // Smi param + assertThrows(() => countArgs(...1), TypeError); + + // Object param + assertThrows(() => countArgs(...{0: 0}), TypeError); + + // Strict arguments + assertEquals(0, countArgs(...arguments)); +} + +tests(); +tests(); +%OptimizeFunctionOnNextCall(tests); +tests(); + +function testRest(...args) { + function countArgs() { return arguments.length; } + assertEquals(3, countArgs(...args)); + assertEquals(4, countArgs(1, ...args)); + assertEquals(5, countArgs(1, 2, ...args)); +} +testRest(1, 2, 3); +testRest(1, 2, 3); +%OptimizeFunctionOnNextCall(testRest); +testRest(1, 2, 3); + +function testRestAndArgs(a, b, ...args) { + function countArgs() { return arguments.length; } + assertEquals(1, countArgs(...args)); + assertEquals(2, countArgs(b, ...args)); + assertEquals(3, countArgs(a, b, ...args)); + assertEquals(4, countArgs(1, a, b, ...args)); + assertEquals(5, countArgs(1, 2, a, b, ...args)); +} +testRestAndArgs(1, 2, 3); +testRestAndArgs(1, 2, 3); +%OptimizeFunctionOnNextCall(testRestAndArgs); +testRestAndArgs(1, 2, 3); + +function testArgumentsStrict() { + "use strict" + function countArgs() { return arguments.length; } + assertEquals(3, countArgs(...arguments)); + assertEquals(4, countArgs(1, ...arguments)); + assertEquals(5, countArgs(1, 2, ...arguments)); +} +testArgumentsStrict(1, 2, 3); +testArgumentsStrict(1, 2, 3); +%OptimizeFunctionOnNextCall(testArgumentsStrict); +testArgumentsStrict(1, 2, 3); + +function testArgumentsSloppy() { + function countArgs() { return arguments.length; } + assertEquals(3, countArgs(...arguments)); + assertEquals(4, countArgs(1, ...arguments)); + assertEquals(5, countArgs(1, 2, ...arguments)); +} +testArgumentsSloppy(1, 2, 3); +testArgumentsSloppy(1, 2, 3); +%OptimizeFunctionOnNextCall(testArgumentsSloppy); +testArgumentsSloppy(1, 2, 3); |