mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
Update the toString/proxy.js to test stringifing functions
This commit is contained in:
parent
29c2384449
commit
ba93cfa52d
@ -1,9 +1,10 @@
|
|||||||
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// Copyright (C) 2016 the Apple Inc. 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.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-object.prototype.tostring
|
esid: sec-object.prototype.tostring
|
||||||
es6id: 19.1.3.6
|
es6id: 19.1.3.6
|
||||||
description: Proxy of an array is treated as an array
|
description: Proxy of an array/function is treated as an array/function
|
||||||
info: |
|
info: |
|
||||||
[...]
|
[...]
|
||||||
3. Let O be ToObject(this value).
|
3. Let O be ToObject(this value).
|
||||||
@ -20,6 +21,14 @@ info: |
|
|||||||
b. Let target be the value of the [[ProxyTarget]] internal slot of
|
b. Let target be the value of the [[ProxyTarget]] internal slot of
|
||||||
argument.
|
argument.
|
||||||
c. Return ? IsArray(target).
|
c. Return ? IsArray(target).
|
||||||
|
|
||||||
|
9.5.14 ProxyCreate(target, handler)
|
||||||
|
|
||||||
|
[...]
|
||||||
|
7. If IsCallable(target) is true, then
|
||||||
|
a. Set the [[Call]] internal method of P as specified in 9.5.12.
|
||||||
|
[...]
|
||||||
|
|
||||||
features: [Proxy]
|
features: [Proxy]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
@ -38,3 +47,50 @@ assert.sameValue(
|
|||||||
'[object Array]',
|
'[object Array]',
|
||||||
'proxy for array proxy'
|
'proxy for array proxy'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
var functionProxy = new Proxy(function() { }, {});
|
||||||
|
var functionProxyProxy = new Proxy(functionProxy, {});
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Object.prototype.toString.call(functionProxy), '[object Function]', 'function proxy'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Object.prototype.toString.call(functionProxyProxy),
|
||||||
|
'[object Function]',
|
||||||
|
'proxy for function proxy'
|
||||||
|
);
|
||||||
|
|
||||||
|
var arrowProxy = new Proxy(() => { }, {});
|
||||||
|
var arrowProxyProxy = new Proxy(arrowProxy, {});
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Object.prototype.toString.call(arrowProxy), '[object Function]', 'arrow function proxy'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Object.prototype.toString.call(arrowProxyProxy),
|
||||||
|
'[object Function]',
|
||||||
|
'proxy for arrow function proxy'
|
||||||
|
);
|
||||||
|
|
||||||
|
var generatorProxy = new Proxy(function*() { }, {});
|
||||||
|
var generatorProxyProxy = new Proxy(generatorProxy, {});
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Object.prototype.toString.call(generatorProxy), '[object GeneratorFunction]', 'generator function proxy'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Object.prototype.toString.call(generatorProxyProxy),
|
||||||
|
'[object GeneratorFunction]',
|
||||||
|
'proxy for generator function proxy'
|
||||||
|
);
|
||||||
|
|
||||||
|
delete generatorProxy.__proto__[Symbol.toStringTag];
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Object.prototype.toString.call(generatorProxy), '[object Function]', 'generator function proxy without Symbol.toStringTag'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Object.prototype.toString.call(generatorProxyProxy),
|
||||||
|
'[object Function]',
|
||||||
|
'proxy for generator function proxy without Symbol.toStringTag'
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user