2016-11-28 21:21:49 +01:00
|
|
|
(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';
|
2016-11-30 02:15:31 +01:00
|
|
|
return doc;
|
2016-11-28 21:21:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
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');
|
|
|
|
})();
|