mirror of https://github.com/tc39/test262.git
Address feedback review
This commit is contained in:
parent
97a04de2de
commit
cf43f93284
|
@ -1,19 +1,32 @@
|
||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es6id: 9.5.13
|
es6id: 9.5.13
|
||||||
esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist
|
esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist
|
||||||
description: >
|
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: >
|
info: >
|
||||||
[[Call]] (thisArgument, argumentsList)
|
[[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) {
|
function target(a, b) {
|
||||||
assert.sameValue(this, ctx);
|
assert.sameValue(this, ctx);
|
||||||
|
calls += 1;
|
||||||
return a + b;
|
return a + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +34,4 @@ var ctx = {};
|
||||||
var p = new Proxy(target, {apply: null});
|
var p = new Proxy(target, {apply: null});
|
||||||
var res = p.call(ctx, 1, 2);
|
var res = p.call(ctx, 1, 2);
|
||||||
assert.sameValue(res, 3, "`apply` trap is `null`");
|
assert.sameValue(res, 3, "`apply` trap is `null`");
|
||||||
|
assert.sameValue(calls, 1, "target is called once");
|
||||||
p = new Proxy(target, {apply: undefined});
|
|
||||||
res = p.call(ctx, 3, 4);
|
|
||||||
assert.sameValue(res, 7, "`apply` trap is `undefined`");
|
|
|
@ -1,19 +1,32 @@
|
||||||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es6id: 9.5.13
|
es6id: 9.5.13
|
||||||
esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist
|
esid: sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist
|
||||||
description: >
|
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: >
|
info: >
|
||||||
[[Call]] (thisArgument, argumentsList)
|
[[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) {
|
function target(a, b) {
|
||||||
assert.sameValue(this, ctx);
|
assert.sameValue(this, ctx);
|
||||||
|
calls += 1;
|
||||||
return a + b;
|
return a + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,3 +34,4 @@ var ctx = {};
|
||||||
var p = new Proxy(target, {});
|
var p = new Proxy(target, {});
|
||||||
var res = p.call(ctx, 1, 2);
|
var res = p.call(ctx, 1, 2);
|
||||||
assert.sameValue(res, 3, "`apply` trap is missing");
|
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,16 +18,16 @@ function Target() {}
|
||||||
function NewTarget() {}
|
function NewTarget() {}
|
||||||
|
|
||||||
var handler = {
|
var handler = {
|
||||||
construct: function(_Target, args, _NewTarget) {
|
construct: function(target, args, newTarget) {
|
||||||
assert.sameValue(this, handler, "trap context is the handler object");
|
assert.sameValue(this, handler, "trap context is the handler object");
|
||||||
assert.sameValue(_Target, Target, "first parameter is the target object");
|
assert.sameValue(target, Target, "first parameter is the target object");
|
||||||
assert.sameValue(args.length, 2, "arguments list contains all construct arguments");
|
assert.sameValue(args.length, 2, "arguments list contains all construct arguments");
|
||||||
|
|
||||||
var a = args[0];
|
var a = args[0];
|
||||||
var b = args[1];
|
var b = args[1];
|
||||||
assert.sameValue(a, 1, "arguments list has first construct argument");
|
assert.sameValue(a, 1, "arguments list has first construct argument");
|
||||||
assert.sameValue(b, 2, "arguments list has second construct argument");
|
assert.sameValue(b, 2, "arguments list has second construct argument");
|
||||||
assert.sameValue(_NewTarget, NewTarget, "newTarget is passed as the third parameter");
|
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.
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
es6id: 9.5.14
|
es6id: 9.5.14
|
||||||
esid: sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget
|
esid: sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget
|
||||||
description: >
|
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: >
|
info: >
|
||||||
[[Construct]] (argumentsList, newTarget)
|
[[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]
|
features: [Reflect.construct]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
var calls = 0;
|
||||||
|
|
||||||
function NewTarget() {}
|
function NewTarget() {}
|
||||||
function Target(a, b) {
|
function Target(a, b) {
|
||||||
assert.sameValue(new.target, NewTarget);
|
assert.sameValue(new.target, NewTarget);
|
||||||
|
calls += 1;
|
||||||
return {sum: a + b};
|
return {sum: a + b};
|
||||||
}
|
}
|
||||||
|
|
||||||
var P = new Proxy(Target, {construct: null});
|
var P = new Proxy(Target, {construct: null});
|
||||||
var obj = Reflect.construct(P, [3, 4], NewTarget);
|
var obj = Reflect.construct(P, [3, 4], NewTarget);
|
||||||
assert.sameValue(obj.sum, 7, "`construct` trap is `null`");
|
assert.sameValue(obj.sum, 7, "`construct` trap is `null`");
|
||||||
|
assert.sameValue(calls, 1, "target is called once");
|
||||||
P = new Proxy(Target, {construct: undefined});
|
|
||||||
obj = Reflect.construct(P, [5, 6], NewTarget);
|
|
||||||
assert.sameValue(obj.sum, 11, "`construct` trap is `undefined`");
|
|
|
@ -4,7 +4,7 @@
|
||||||
es6id: 9.5.14
|
es6id: 9.5.14
|
||||||
esid: sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget
|
esid: sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget
|
||||||
description: >
|
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: >
|
info: >
|
||||||
[[Construct]] (argumentsList, newTarget)
|
[[Construct]] (argumentsList, newTarget)
|
||||||
|
|
||||||
|
@ -13,12 +13,16 @@ info: >
|
||||||
features: [Reflect.construct]
|
features: [Reflect.construct]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
var calls = 0;
|
||||||
|
|
||||||
function NewTarget() {}
|
function NewTarget() {}
|
||||||
function Target(a, b) {
|
function Target(a, b) {
|
||||||
assert.sameValue(new.target, NewTarget);
|
assert.sameValue(new.target, NewTarget);
|
||||||
|
calls += 1;
|
||||||
return {sum: a + b};
|
return {sum: a + b};
|
||||||
}
|
}
|
||||||
|
|
||||||
var P = new Proxy(Target, {});
|
var P = new Proxy(Target, {});
|
||||||
var obj = Reflect.construct(P, [1, 2], NewTarget);
|
var obj = Reflect.construct(P, [1, 2], NewTarget);
|
||||||
assert.sameValue(obj.sum, 3, "`construct` trap is missing");
|
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