{"ScriptPreparationCode":"function function_with_try_finally(array) {\r\n try {\r\n array.push(Math.random() * 1000000)\r\n array.push(Math.random() * 1000000)\r\n // Simulating some workload\r\n let sum = 0\r\n for (let i = 0; i \u003C 100; i\u002B\u002B) {\r\n for (let j = 0; j \u003C i; j\u002B\u002B) {\r\n sum \u002B= j * j\r\n }\r\n }\r\n // Randomly deciding whether to exit early\r\n if (Math.random() \u003C 0.3) {\r\n return sum\r\n }\r\n // More workload\r\n for (let i = 0; i \u003C 1000; i\u002B\u002B) {\r\n for (let j = 0; j \u003C 10; j\u002B\u002B) {\r\n sum \u002B= j * j\r\n }\r\n }\r\n // Another random exit point\r\n if (Math.random() \u003C 0.6) {\r\n return sum\r\n }\r\n if (array.length \u003C 500) {\r\n function_with_try_finally(array)\r\n return 0\r\n }\r\n } finally {\r\n // Cleanup action: array.pop()\r\n array.pop()\r\n }\r\n return -1\r\n}\r\n\r\nfunction function_with_explicit_cleanup(array) {\r\n array.push(Math.random() * 1000000)\r\n array.push(Math.random() * 1000000)\r\n // Simulating some workload\r\n let sum = 0\r\n for (let i = 0; i \u003C 100; i\u002B\u002B) {\r\n for (let j = 0; j \u003C i; j\u002B\u002B) {\r\n sum \u002B= j * j\r\n }\r\n }\r\n // Randomly deciding whether to exit early\r\n if (Math.random() \u003C 0.3) {\r\n array.pop()\r\n return sum\r\n }\r\n // More workload\r\n for (let i = 0; i \u003C 1000; i\u002B\u002B) {\r\n for (let j = 0; j \u003C 10; j\u002B\u002B) {\r\n sum \u002B= j * j\r\n }\r\n }\r\n // Another random exit point\r\n if (Math.random() \u003C 0.6) {\r\n array.pop()\r\n return sum\r\n }\r\n if (array.length \u003C 500) {\r\n function_with_try_finally(array)\r\n array.pop()\r\n return 0\r\n }\r\n // Cleanup action: array.pop()\r\n array.pop()\r\n return -1\r\n}","TestCases":[{"Name":"Try finally","Code":"function_with_try_finally([])","IsDeferred":false},{"Name":"Without try finally","Code":"function_with_explicit_cleanup([])","IsDeferred":false}]}