0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-24 00:47:50 +01:00
posthog/hogvm/__tests__/printLoops.hog
2024-07-10 15:11:15 +02:00

23 lines
582 B
Plaintext

// Printing recursive objects.
let obj := {'key': 'value', 'key2': 'value2'}
let str := 'na'
for (let i := 0; i < 100; i := i + 1) {
str := str || 'na'
obj[f'key_{i}'] := {
'wasted': 'memory: ' || str || ' batman!',
'something': obj, // something links to obj
}
}
// printing works without loops
print(obj)
// this doesn't crash
let json := jsonStringify(obj)
// Commented out because JSON output is slightly different in python vs nodejs
// print(json)
// Should be equal to the original printed object -> nulls instead of recursive nodes
print(jsonParse(json))