blob: 886e9cf37841c50153dd91fc8164ed9daf9bd747 (
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
|
(function() {
"use strict";
const tooMuchRecursion = (1 << 16);
const nestobj = (depth) => {
let doc = {};
let cur = doc;
for (let i = 0; i < depth; i++) {
cur[i] = {};
cur = cur[i];
}
cur['a'] = 'foo';
return doc;
};
const nestarr = (depth) => {
let doc = [0];
let cur = doc;
for (let i = 0; i < depth; i++) {
cur[0] = [0];
cur = cur[0];
}
cur[0] = 'foo';
return doc;
};
assert.doesNotThrow(tojson, [nestobj(tooMuchRecursion)], 'failed to print deeply nested object');
assert.doesNotThrow(tojson, [nestarr(tooMuchRecursion)], 'failed to print deeply nested array');
})();
|