Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/JSON/stringify/value-proxy.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-object.prototype.tostring
5 es6id: 19.1.3.6
6 description: Proxy of an array is treated as an array
7 info: |
8 [...]
9 3. Let O be ToObject(this value).
10 4. Let isArray be ? IsArray(O).
11 5. If isArray is true, let builtinTag be "Array".
12 [...]
13
14 7.2.2 IsArray
15
16 [...]
17 3. If argument is a Proxy exotic object, then
18 a. If the value of the [[ProxyHandler]] internal slot of argument is null,
19 throw a TypeError exception.
20 b. Let target be the value of the [[ProxyTarget]] internal slot of
21 argument.
22 c. Return ? IsArray(target).
23 features: [Proxy]
24 ---*/
25
26 var objectProxy = new Proxy({}, {});
27 var arrayProxy = new Proxy([], {});
28 var arrayProxyProxy = new Proxy(arrayProxy, {});
29
30 assert.sameValue(
31 Object.prototype.toString.call(objectProxy), '[object Object]'
32 );
33 assert.sameValue(
34 Object.prototype.toString.call(arrayProxy), '[object Array]', 'array proxy'
35 );
36 assert.sameValue(
37 Object.prototype.toString.call(arrayProxyProxy),
38 '[object Array]',
39 'proxy for array proxy'
40 );