summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/builtins/JSON/JSON.stringify-proxy.js
blob: 4db7b22b4104e831ba5ebd80d93cef67cb93c92a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
load("test-common.js");

try {
    let p = new Proxy([], {
        get(_, key) {
            if (key === "length")
                return 3;
            return Number(key);
        },
    });

    assert(JSON.stringify(p) === "[0,1,2]");
    assert(JSON.stringify([[new Proxy(p, {})]]) === "[[[0,1,2]]]");

    console.log("PASS");
} catch (e) {
    console.log("FAIL: " + e);
}