| 1 |
// Copyright (C) 2015 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
es6id: 26.1.1 |
| 5 |
description: > |
| 6 |
Call target with thisArgument and argumentsList |
| 7 |
info: | |
| 8 |
26.1.1 Reflect.apply ( target, thisArgument, argumentsList ) |
| 9 |
|
| 10 |
... |
| 11 |
4. Perform PrepareForTailCall(). |
| 12 |
5. Return Call(target, thisArgument, args). |
| 13 |
---*/ |
| 14 |
|
| 15 |
var o = {}; |
| 16 |
var count = 0; |
| 17 |
var results, args; |
| 18 |
|
| 19 |
function fn() { |
| 20 |
count++; |
| 21 |
results = { |
| 22 |
thisArg: this, |
| 23 |
args: arguments |
| 24 |
}; |
| 25 |
} |
| 26 |
|
| 27 |
Reflect.apply(fn, o, ['arg1', 2, , null]); |
| 28 |
|
| 29 |
assert.sameValue(count, 1, 'Called target once'); |
| 30 |
assert.sameValue(results.thisArg, o, 'Called target with `o` as `this` object'); |
| 31 |
assert.sameValue(results.args.length, 4, 'Called target with 4 arguments'); |
| 32 |
assert.sameValue(results.args[0], 'arg1'); |
| 33 |
assert.sameValue(results.args[1], 2); |
| 34 |
assert.sameValue(results.args[2], undefined); |
| 35 |
assert.sameValue(results.args[3], null); |