Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Proxy/construct/call-parameters.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 es6id: 9.5.14
5 description: >
6 trap is called with handler object as its context, and parameters are:
7 target, an array list with the called arguments and the new target, and the
8 constructor new.target.
9 info: |
10 [[Construct]] ( argumentsList, newTarget)
11
12 9. Let newObj be Call(trap, handler, «target, argArray, newTarget »).
13 ---*/
14
15 var _target, _handler, _args, _P;
16
17 function Target() {}
18
19 var handler = {
20 construct: function(t, args, newTarget) {
21 _handler = this;
22 _target = t;
23 _args = args;
24 _P = newTarget;
25
26 return new t(args[0], args[1]);
27 }
28 };
29 var P = new Proxy(Target, handler);
30
31 new P(1, 2);
32
33 assert.sameValue(_handler, handler, "trap context is the handler object");
34 assert.sameValue(_target, Target, "first parameter is the target object");
35 assert.sameValue(_args.length, 2, "arguments list contains all call arguments");
36 assert.sameValue(_args[0], 1, "arguments list has first call argument");
37 assert.sameValue(_args[1], 2, "arguments list has second call argument");
38 assert.sameValue(_P, P, "constructor is sent as the third parameter");