Skip to content
Snippets Groups Projects
Commit ba93cfa5 authored by Keith Miller's avatar Keith Miller
Browse files

Update the toString/proxy.js to test stringifing functions

parent 29c23844
No related branches found
No related tags found
No related merge requests found
// 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: | ...@@ -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( ...@@ -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'
);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment