From 1e18a162c4fce07ec273a22f6f4bedd4f91038c6 Mon Sep 17 00:00:00 2001 From: sergeych Date: Mon, 22 Dec 2025 12:59:11 +0100 Subject: [PATCH] added exception reporting tests --- lynglib/src/commonTest/kotlin/ScriptTest.kt | 38 +++++++++++++++++++++ site/src/jsMain/resources/index.html | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lynglib/src/commonTest/kotlin/ScriptTest.kt b/lynglib/src/commonTest/kotlin/ScriptTest.kt index b45b004..f919cca 100644 --- a/lynglib/src/commonTest/kotlin/ScriptTest.kt +++ b/lynglib/src/commonTest/kotlin/ScriptTest.kt @@ -4375,4 +4375,42 @@ class ScriptTest { """.trimIndent()) } + + @Test + fun testProperlyReportExceptionPos() = runTest { + var x = assertFailsWith { + eval( + """ + val tmp = 11 + + if( tmp < 100 ) { + throw "success" + } + """.trimIndent() + ) + } + println(x) + assertEquals(3, x.pos.line) + assertContains(x.message!!, "throw \"success\"") + + // comments shoudl not change reporting: + x = assertFailsWith { + eval( + """ + val tmp = 11 + /* + This should not change position: + */ + fun test() { + throw "success" + } + test() + """.trimIndent() + ) + } + println(x) + assertEquals(5, x.pos.line) + assertContains(x.message!!, "throw \"success\"") + + } } diff --git a/site/src/jsMain/resources/index.html b/site/src/jsMain/resources/index.html index 795d68e..ca3a588 100644 --- a/site/src/jsMain/resources/index.html +++ b/site/src/jsMain/resources/index.html @@ -329,7 +329,7 @@
- v1.0.8-SNAPSHOT + v1.0.10-SNAPSHOT