Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Proxy/construct/trap-is-undefined.js

raw
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 /*---
5 es6id: 9.5.14
6 esid: sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget
7 description: >
8 If the construct trap value is undefined, propagate the construct to the target object.
9 info: |
10 [[Construct]] (argumentsList, newTarget)
11
12 ...
13 5. Let trap be ? GetMethod(handler, "construct").
14 6. If trap is undefined, then
15 a. Assert: target has a [[Construct]] internal method.
16 b. Return ? Construct(target, argumentsList, newTarget).
17 ...
18
19 GetMethod ( V, P )
20
21 ...
22 3. If func is either undefined or null, return undefined.
23 ...
24 features: [Reflect.construct]
25 ---*/
26
27 var calls = 0;
28
29 function NewTarget() {}
30
31 function Target(a, b) {
32 assert.sameValue(new.target, NewTarget);
33 calls += 1;
34 return {
35 sum: a + b
36 };
37 }
38
39 var P = new Proxy(Target, {
40 construct: undefined
41 });
42 var obj = Reflect.construct(P, [3, 4], NewTarget);
43 assert.sameValue(obj.sum, 7, "`construct` trap is `undefined`");
44 assert.sameValue(calls, 1, "target is called once");