mirror of https://github.com/tc39/test262.git
improve & join undefined apply tests
This commit is contained in:
parent
8e5ffb66bf
commit
97a04de2de
|
@ -2,8 +2,9 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 9.5.13
|
||||
esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist
|
||||
description: >
|
||||
If trap is undefined, propagate the call to the target object.
|
||||
If trap is null or undefined, propagate the call to the target object.
|
||||
info: >
|
||||
[[Call]] (thisArgument, argumentsList)
|
||||
|
||||
|
@ -11,9 +12,12 @@ info: >
|
|||
argumentsList).
|
||||
---*/
|
||||
|
||||
var target = function(a, b) {
|
||||
function target(a, b) {
|
||||
assert.sameValue(this, ctx);
|
||||
return a + b;
|
||||
};
|
||||
var p = new Proxy(target, {});
|
||||
}
|
||||
|
||||
assert.sameValue(p(1, 2), 3);
|
||||
var ctx = {};
|
||||
var p = new Proxy(target, {});
|
||||
var res = p.call(ctx, 1, 2);
|
||||
assert.sameValue(res, 3, "`apply` trap is missing");
|
|
@ -0,0 +1,27 @@
|
|||
// 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.13
|
||||
esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist
|
||||
description: >
|
||||
If trap is null or undefined, propagate the call to the target object.
|
||||
info: >
|
||||
[[Call]] (thisArgument, argumentsList)
|
||||
|
||||
7. If trap is undefined, then Return Call(target, thisArgument,
|
||||
argumentsList).
|
||||
---*/
|
||||
|
||||
function target(a, b) {
|
||||
assert.sameValue(this, ctx);
|
||||
return a + b;
|
||||
}
|
||||
|
||||
var ctx = {};
|
||||
var p = new Proxy(target, {apply: null});
|
||||
var res = p.call(ctx, 1, 2);
|
||||
assert.sameValue(res, 3, "`apply` trap is `null`");
|
||||
|
||||
p = new Proxy(target, {apply: undefined});
|
||||
res = p.call(ctx, 3, 4);
|
||||
assert.sameValue(res, 7, "`apply` trap is `undefined`");
|
|
@ -1,21 +0,0 @@
|
|||
// 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.13
|
||||
description: >
|
||||
If trap is undefined, propagate the call to the target object.
|
||||
info: >
|
||||
[[Call]] (thisArgument, argumentsList)
|
||||
|
||||
7. If trap is undefined, then Return Call(target, thisArgument,
|
||||
argumentsList).
|
||||
---*/
|
||||
|
||||
var target = function(a, b) {
|
||||
return a + b;
|
||||
};
|
||||
var p = new Proxy(target, {
|
||||
apply: undefined
|
||||
});
|
||||
|
||||
assert.sameValue(p(1, 2), 3);
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (C) 2017 Aleksey Shvayka. 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: >
|
||||
trap is called with handler object as its context, and parameters are:
|
||||
target, an array list with the called arguments and the NewTarget
|
||||
info: >
|
||||
[[Construct]] (argumentsList, newTarget)
|
||||
|
||||
9. Let newObj be Call(trap, handler, «target, argArray, newTarget»).
|
||||
features: [Reflect.construct]
|
||||
---*/
|
||||
|
||||
function Target() {}
|
||||
function NewTarget() {}
|
||||
|
||||
var handler = {
|
||||
construct: function(_Target, args, _NewTarget) {
|
||||
assert.sameValue(this, handler, "trap context is the handler object");
|
||||
assert.sameValue(_Target, Target, "first parameter is the target object");
|
||||
assert.sameValue(args.length, 2, "arguments list contains all construct arguments");
|
||||
|
||||
var a = args[0];
|
||||
var b = args[1];
|
||||
assert.sameValue(a, 1, "arguments list has first construct argument");
|
||||
assert.sameValue(b, 2, "arguments list has second construct argument");
|
||||
assert.sameValue(_NewTarget, NewTarget, "newTarget is passed as the third parameter");
|
||||
|
||||
return {sum: a + b};
|
||||
},
|
||||
};
|
||||
|
||||
var P = new Proxy(Target, handler);
|
||||
var res = Reflect.construct(P, [1, 2], NewTarget);
|
||||
assert.sameValue(res.sum, 3);
|
|
@ -20,7 +20,7 @@ info: >
|
|||
a. Let realm be ? GetFunctionRealm(constructor).
|
||||
b. Let proto be realm's intrinsic object named intrinsicDefaultProto.
|
||||
[...]
|
||||
features: [Reflect]
|
||||
features: [Reflect.construct]
|
||||
---*/
|
||||
|
||||
var other = $262.createRealm().global;
|
|
@ -0,0 +1,24 @@
|
|||
// 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: >
|
||||
If trap is null or undefined, propagate the construct to the target object.
|
||||
info: >
|
||||
[[Construct]] (argumentsList, newTarget)
|
||||
|
||||
7. If trap is undefined, then
|
||||
b. Return Construct(target, argumentsList, newTarget).
|
||||
features: [Reflect.construct]
|
||||
---*/
|
||||
|
||||
function NewTarget() {}
|
||||
function Target(a, b) {
|
||||
assert.sameValue(new.target, NewTarget);
|
||||
return {sum: a + b};
|
||||
}
|
||||
|
||||
var P = new Proxy(Target, {});
|
||||
var obj = Reflect.construct(P, [1, 2], NewTarget);
|
||||
assert.sameValue(obj.sum, 3, "`construct` trap is missing");
|
|
@ -0,0 +1,28 @@
|
|||
// 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: >
|
||||
If trap is null or undefined, propagate the construct to the target object.
|
||||
info: >
|
||||
[[Construct]] (argumentsList, newTarget)
|
||||
|
||||
7. If trap is undefined, then
|
||||
b. Return Construct(target, argumentsList, newTarget).
|
||||
features: [Reflect.construct]
|
||||
---*/
|
||||
|
||||
function NewTarget() {}
|
||||
function Target(a, b) {
|
||||
assert.sameValue(new.target, NewTarget);
|
||||
return {sum: a + b};
|
||||
}
|
||||
|
||||
var P = new Proxy(Target, {construct: null});
|
||||
var obj = Reflect.construct(P, [3, 4], NewTarget);
|
||||
assert.sameValue(obj.sum, 7, "`construct` trap is `null`");
|
||||
|
||||
P = new Proxy(Target, {construct: undefined});
|
||||
obj = Reflect.construct(P, [5, 6], NewTarget);
|
||||
assert.sameValue(obj.sum, 11, "`construct` trap is `undefined`");
|
|
@ -1,19 +0,0 @@
|
|||
// 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
|
||||
description: >
|
||||
If trap is undefined, propagate the construct to the target object.
|
||||
info: >
|
||||
[[Construct]] ( argumentsList, newTarget)
|
||||
|
||||
7. If trap is undefined, then
|
||||
b. Return Construct(target, argumentsList, newTarget).
|
||||
---*/
|
||||
|
||||
function Target(arg) {
|
||||
this.attr = arg;
|
||||
}
|
||||
var P = new Proxy(Target, {});
|
||||
|
||||
assert.sameValue((new P("foo")).attr, "foo");
|
|
@ -1,21 +0,0 @@
|
|||
// 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
|
||||
description: >
|
||||
If trap is undefined, propagate the construct to the target object.
|
||||
info: >
|
||||
[[Construct]] ( argumentsList, newTarget)
|
||||
|
||||
7. If trap is undefined, then
|
||||
b. Return Construct(target, argumentsList, newTarget).
|
||||
---*/
|
||||
|
||||
function Target(arg) {
|
||||
this.attr = arg;
|
||||
}
|
||||
var P = new Proxy(Target, {
|
||||
construct: undefined
|
||||
});
|
||||
|
||||
assert.sameValue((new P("foo")).attr, "foo");
|
Loading…
Reference in New Issue