From bb862e6cb5002d865b9b2953342127f43c0dbdcb Mon Sep 17 00:00:00 2001 From: sergeych Date: Fri, 13 Jun 2025 01:52:44 +0400 Subject: [PATCH] refs #22 test for try-free --- library/src/commonTest/kotlin/ScriptTest.kt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/library/src/commonTest/kotlin/ScriptTest.kt b/library/src/commonTest/kotlin/ScriptTest.kt index 53098d0..7dad62e 100644 --- a/library/src/commonTest/kotlin/ScriptTest.kt +++ b/library/src/commonTest/kotlin/ScriptTest.kt @@ -1833,4 +1833,25 @@ class ScriptTest { """.trimIndent()) } + @Test + fun testTryFinally() = runTest { + val c = Context() + assertFails { + c.eval( + """ + var resource = "used" + try { + throw "test" + } + finally { + resource = "freed" + } + """.trimIndent() + ) + } + c.eval(""" + assertEquals("freed", resource) + """.trimIndent()) + } + } \ No newline at end of file