| 1 |
// Copyright (C) 2016 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
esid: sec-reflect.construct |
| 5 |
es6id: 26.1.2 |
| 6 |
description: Value when invoked via `Reflect.construct` |
| 7 |
info: | |
| 8 |
[...] |
| 9 |
2. If newTarget is not present, let newTarget be target. |
| 10 |
[...] |
| 11 |
5. Return ? Construct(target, args, newTarget). |
| 12 |
features: [Reflect] |
| 13 |
---*/ |
| 14 |
|
| 15 |
var customNewTarget = function() {}; |
| 16 |
var newTarget = null; |
| 17 |
|
| 18 |
function f() { |
| 19 |
newTarget = new.target; |
| 20 |
} |
| 21 |
|
| 22 |
Reflect.construct(f, []); |
| 23 |
|
| 24 |
assert.sameValue(newTarget, f, 'NewTarget unspecified'); |
| 25 |
|
| 26 |
Reflect.construct(f, [], customNewTarget); |
| 27 |
|
| 28 |
assert.sameValue(newTarget, customNewTarget, 'NewTarget explicitly defined'); |