summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/structured-clone/roundtrip.js
blob: ef7732ea073b39d2cb03c712490f18faa91caf5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/
 */

load(libdir + "asserts.js");

const objects = [
    {},
    {a: 1, b: 2},
    {0: 1, 1: 2},
    {0: 1, 1: 2, a: 1},
    {0: 1, 1: 2, a: 1, b: 2},
    {1000000: 0, 1000001: 1},
    {0: 0, 1: 0, 1000000: 0, 1000001: 1},

    [],
    [0, 1, 2],
    [0, 15, 16],
    [{a: 0, b: 0}, {b: 0, a: 0}],
    [0, , , 1, 2],
    [, 1],
    [0,,],
    [,,],
]

for (const obj of objects) {
    assertDeepEq(deserialize(serialize(obj)), obj);
    assertDeepEq(deserialize(serialize(wrapWithProto(obj, null))), obj);
}