From 2afa67da53afd421f8559e9603e294295ecf8145 Mon Sep 17 00:00:00 2001 From: Alexey Volkov Date: Wed, 13 Sep 2023 12:47:39 +0300 Subject: [PATCH] Wrong work with kotlin ranges #175 --- .../testing/cfg/KotlinInstructionsTest.kt | 3 +++ .../kotlin/org/jacodb/testing/cfg/Ranges.kt | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/jacodb-core/src/test/kotlin/org/jacodb/testing/cfg/KotlinInstructionsTest.kt b/jacodb-core/src/test/kotlin/org/jacodb/testing/cfg/KotlinInstructionsTest.kt index 6fe95bd57..287c9fb72 100644 --- a/jacodb-core/src/test/kotlin/org/jacodb/testing/cfg/KotlinInstructionsTest.kt +++ b/jacodb-core/src/test/kotlin/org/jacodb/testing/cfg/KotlinInstructionsTest.kt @@ -41,6 +41,9 @@ class KotlinInstructionsTest: BaseInstructionsTest() { @Test fun `kotlin range test`() = runKotlinTest(Ranges::class.java.name) + @Test + fun `kotlin range test 2`() = runKotlinTest(Ranges2::class.java.name) + @Test fun `kotlin overloading test`() = runKotlinTest(Overloading::class.java.name) diff --git a/jacodb-core/src/testFixtures/kotlin/org/jacodb/testing/cfg/Ranges.kt b/jacodb-core/src/testFixtures/kotlin/org/jacodb/testing/cfg/Ranges.kt index 761a66215..6ae57ced4 100644 --- a/jacodb-core/src/testFixtures/kotlin/org/jacodb/testing/cfg/Ranges.kt +++ b/jacodb-core/src/testFixtures/kotlin/org/jacodb/testing/cfg/Ranges.kt @@ -68,4 +68,30 @@ class Ranges { } +} + +class Ranges2 { + + fun isDigit(a: Int) : String { + val aa = ArrayList () + aa.add(239) + + return when(a) { + in aa -> "array list" + in 0..9 -> "digit" + !in 0..100 -> "not small" + else -> "something" + } + } + + fun assertDigit(i: Int, expected: String): String { + val result = isDigit(i) + return if (result == expected) "" else "fail: isDigit($i) = \"$result\"" + } + + fun box(): String { + val result = assertDigit(0, "digit") + if (result == "") return "OK" + return result + } } \ No newline at end of file