Skip to content

Commit

Permalink
Wrong work with kotlin ranges #175
Browse files Browse the repository at this point in the history
  • Loading branch information
lehvolk committed Sep 26, 2023
1 parent a9857f1 commit 2afa67d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,30 @@ class Ranges {
}


}

class Ranges2 {

fun isDigit(a: Int) : String {
val aa = ArrayList<Int> ()
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
}
}

0 comments on commit 2afa67d

Please sign in to comment.