mirror of https://github.com/tc39/test262.git
Address feedback review
This commit is contained in:
parent
97a04de2de
commit
cf43f93284
|
@ -1,27 +1,37 @@
|
|||
// 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.
|
||||
If the apply trap value is null, propagate the call to the target object.
|
||||
info: >
|
||||
[[Call]] (thisArgument, argumentsList)
|
||||
|
||||
7. If trap is undefined, then Return Call(target, thisArgument,
|
||||
argumentsList).
|
||||
...
|
||||
5. Let trap be ? GetMethod(handler, "apply").
|
||||
6. If trap is undefined, then
|
||||
a. Return ? Call(target, thisArgument, argumentsList).
|
||||
...
|
||||
|
||||
GetMethod ( V, P )
|
||||
|
||||
...
|
||||
3. If func is either undefined or null, return undefined.
|
||||
...
|
||||
---*/
|
||||
|
||||
var calls = 0;
|
||||
|
||||
function target(a, b) {
|
||||
assert.sameValue(this, ctx);
|
||||
return a + b;
|
||||
assert.sameValue(this, ctx);
|
||||
calls += 1;
|
||||
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`");
|
||||
assert.sameValue(calls, 1, "target is called once");
|
|
@ -1,19 +1,32 @@
|
|||
// 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.
|
||||
If trap is not set, propagate the call to the target object.
|
||||
info: >
|
||||
[[Call]] (thisArgument, argumentsList)
|
||||
|
||||
7. If trap is undefined, then Return Call(target, thisArgument,
|
||||
argumentsList).
|
||||
...
|
||||
5. Let trap be ? GetMethod(handler, "apply").
|
||||
6. If trap is undefined, then
|
||||
a. Return ? Call(target, thisArgument, argumentsList).
|
||||
...
|
||||
|
||||
GetMethod ( V, P )
|
||||
|
||||
...
|
||||
3. If func is either undefined or null, return undefined.
|
||||
...
|
||||
---*/
|
||||
|
||||
var calls = 0;
|
||||
|
||||
function target(a, b) {
|
||||
assert.sameValue(this, ctx);
|
||||
calls += 1;
|
||||
return a + b;
|
||||
}
|
||||
|
||||
|
@ -21,3 +34,4 @@ var ctx = {};
|
|||
var p = new Proxy(target, {});
|
||||
var res = p.call(ctx, 1, 2);
|
||||
assert.sameValue(res, 3, "`apply` trap is missing");
|
||||
assert.sameValue(calls, 1, "target is called once");
|
|
@ -0,0 +1,37 @@
|
|||
// 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 the apply trap value is undefined, propagate the call to the target object.
|
||||
info: >
|
||||
[[Call]] (thisArgument, argumentsList)
|
||||
|
||||
...
|
||||
5. Let trap be ? GetMethod(handler, "apply").
|
||||
6. If trap is undefined, then
|
||||
a. Return ? Call(target, thisArgument, argumentsList).
|
||||
...
|
||||
|
||||
GetMethod ( V, P )
|
||||
|
||||
...
|
||||
3. If func is either undefined or null, return undefined.
|
||||
...
|
||||
---*/
|
||||
|
||||
var calls = 0;
|
||||
|
||||
function target(a, b) {
|
||||
assert.sameValue(this, ctx);
|
||||
calls += 1;
|
||||
return a + b;
|
||||
}
|
||||
|
||||
var ctx = {};
|
||||
var p = new Proxy(target, {apply: undefined});
|
||||
var res = p.call(ctx, 1, 2);
|
||||
assert.sameValue(res, 3, "`apply` trap is `null`");
|
||||
assert.sameValue(calls, 1, "target is called once");
|
|
@ -18,18 +18,18 @@ 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");
|
||||
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");
|
||||
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};
|
||||
return {sum: a + b};
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -1,28 +1,39 @@
|
|||
// 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.
|
||||
If the construct trap value is null, propagate the construct to the target object.
|
||||
info: >
|
||||
[[Construct]] (argumentsList, newTarget)
|
||||
|
||||
7. If trap is undefined, then
|
||||
b. Return Construct(target, argumentsList, newTarget).
|
||||
...
|
||||
5. Let trap be ? GetMethod(handler, "construct").
|
||||
6. If trap is undefined, then
|
||||
a. Assert: target has a [[Construct]] internal method.
|
||||
b. Return ? Construct(target, argumentsList, newTarget).
|
||||
...
|
||||
|
||||
GetMethod ( V, P )
|
||||
|
||||
...
|
||||
3. If func is either undefined or null, return undefined.
|
||||
...
|
||||
features: [Reflect.construct]
|
||||
---*/
|
||||
|
||||
var calls = 0;
|
||||
|
||||
function NewTarget() {}
|
||||
function Target(a, b) {
|
||||
assert.sameValue(new.target, NewTarget);
|
||||
calls += 1;
|
||||
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`");
|
||||
assert.sameValue(calls, 1, "target is called once");
|
|
@ -4,7 +4,7 @@
|
|||
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.
|
||||
If the construct trap is not set, propagate the construct to the target object.
|
||||
info: >
|
||||
[[Construct]] (argumentsList, newTarget)
|
||||
|
||||
|
@ -13,12 +13,16 @@ info: >
|
|||
features: [Reflect.construct]
|
||||
---*/
|
||||
|
||||
var calls = 0;
|
||||
|
||||
function NewTarget() {}
|
||||
function Target(a, b) {
|
||||
assert.sameValue(new.target, NewTarget);
|
||||
calls += 1;
|
||||
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");
|
||||
assert.sameValue(calls, 1, "target is called once");
|
|
@ -0,0 +1,39 @@
|
|||
// 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 the construct trap value is undefined, propagate the construct to the target object.
|
||||
info: >
|
||||
[[Construct]] (argumentsList, newTarget)
|
||||
|
||||
...
|
||||
5. Let trap be ? GetMethod(handler, "construct").
|
||||
6. If trap is undefined, then
|
||||
a. Assert: target has a [[Construct]] internal method.
|
||||
b. Return ? Construct(target, argumentsList, newTarget).
|
||||
...
|
||||
|
||||
GetMethod ( V, P )
|
||||
|
||||
...
|
||||
3. If func is either undefined or null, return undefined.
|
||||
...
|
||||
features: [Reflect.construct]
|
||||
---*/
|
||||
|
||||
var calls = 0;
|
||||
|
||||
function NewTarget() {}
|
||||
function Target(a, b) {
|
||||
assert.sameValue(new.target, NewTarget);
|
||||
calls += 1;
|
||||
return {sum: a + b};
|
||||
}
|
||||
|
||||
var P = new Proxy(Target, {construct: undefined});
|
||||
var obj = Reflect.construct(P, [3, 4], NewTarget);
|
||||
assert.sameValue(obj.sum, 7, "`construct` trap is `undefined`");
|
||||
assert.sameValue(calls, 1, "target is called once");
|
Loading…
Reference in New Issue