test262/test/built-ins/Proxy/construct/trap-is-undefined-no-proper...

32 lines
890 B
JavaScript
Raw Normal View History

2017-06-27 01:33:35 +02:00
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 9.5.14
esid: sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget
description: >
2017-09-06 21:52:05 +02:00
If the construct trap is not set, propagate the construct to the target object.
info: |
2017-06-27 01:33:35 +02:00
[[Construct]] (argumentsList, newTarget)
7. If trap is undefined, then
b. Return Construct(target, argumentsList, newTarget).
features: [Reflect.construct]
---*/
2017-09-06 21:52:05 +02:00
var calls = 0;
2017-06-27 01:33:35 +02:00
function NewTarget() {}
2017-06-27 01:33:35 +02:00
function Target(a, b) {
assert.sameValue(new.target, NewTarget);
calls += 1;
return {
sum: a + b
};
2017-06-27 01:33:35 +02:00
}
var P = new Proxy(Target, {});
var obj = Reflect.construct(P, [1, 2], NewTarget);
assert.sameValue(obj.sum, 3, "`construct` trap is missing");
2017-09-06 21:52:05 +02:00
assert.sameValue(calls, 1, "target is called once");