You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
23 KiB

/*---
{
"custom": true
}
---*/
/*===
{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":"bar"}}}}}}}}}}
{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":{"foo":"bar"}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
Error
[[[[[[[[[["bar"]]]]]]]]]]
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["bar"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
Error
{"foo":[{"foo":[{"foo":[{"foo":[{"foo":["bar"]}]}]}]}]}
{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":[{"foo":["bar"]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}
Error
===*/
/* JSON stringify() recursion limit is hit if C recursion through object
* and/or array traversal becomes too deep.
*/
function objectRecursionTest(n) {
var obj = 'bar';
var i;
for (i = 0; i < n; i++) {
obj = { foo: obj };
}
print(JSON.stringify(obj));
}
function arrayRecursionTest(n) {
var obj = 'bar';
var i;
for (i = 0; i < n; i++) {
obj = [ obj ];
}
print(JSON.stringify(obj));
}
function objectAndArrayRecursionTest(n) {
var obj = 'bar';
var i;
for (i = 0; i < n; i++) {
if (i % 2) {
obj = { foo: obj };
} else {
obj = [ obj ];
}
}
print(JSON.stringify(obj));
}
try {
objectRecursionTest(10);
objectRecursionTest(80);
objectRecursionTest(200);
} catch (e) {
print(e.name);
}
try {
arrayRecursionTest(10);
arrayRecursionTest(80);
arrayRecursionTest(200);
} catch (e) {
print(e.name);
}
try {
objectAndArrayRecursionTest(10);
objectAndArrayRecursionTest(80);
objectAndArrayRecursionTest(200);
} catch (e) {
print(e.name);
}
/*===
[{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}]]
[{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}]]
[{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{"foo":1}],{"foo":1,"bar":[1,2]},[1,{
===*/
/* A very wide structure is not an issue, as long as there is no (C)
* recursion. This test ensures that the recursion tracking works
* correctly, i.e. is increased and decreased where appropriate.
*/
function noRecursionTest(n) {
var obj = [];
var i;
for (i = 0; i < n; i++) {
if (i % 2) {
obj.push([1, { foo: 1 }]);
} else {
obj.push({ foo: 1, bar: [1, 2] });
}
}
print(JSON.stringify(obj));
}
try {
noRecursionTest(10);
noRecursionTest(100);
noRecursionTest(1000);
} catch (e) {
print(e.name, e);
}