summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/expressions/new.target/value-via-reflect-construct.js
blob: 6e157d465bedb2bb1307a6d7c5967ccb94064d39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-reflect.construct
es6id: 26.1.2
description: Value when invoked via `Reflect.construct`
info: |
  [...]
  2. If newTarget is not present, let newTarget be target.
  [...]
  5. Return ? Construct(target, args, newTarget).
features: [new.target, Reflect, Reflect.construct]
---*/

var customNewTarget = function() {};
var newTarget = null;

function f() {
  newTarget = new.target;
}

Reflect.construct(f, []);

assert.sameValue(newTarget, f, 'NewTarget unspecified');

Reflect.construct(f, [], customNewTarget);

assert.sameValue(newTarget, customNewTarget, 'NewTarget explicitly defined');

reportCompare(0, 0);