mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
32 lines
762 B
JavaScript
32 lines
762 B
JavaScript
(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');
|
|
})();
|