Add ir interpreter tests
This commit is contained in:
committed by
TeamCityServer
parent
cc2d7340dc
commit
e28ab45c51
@@ -0,0 +1,22 @@
|
||||
import kotlin.*
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getArrayElement(array: IntArray, index: Int): Int {
|
||||
try {
|
||||
return array[index]
|
||||
} catch (e: IndexOutOfBoundsException) {
|
||||
throw IllegalArgumentException("Index must be less than array size and greater than zero", e)
|
||||
}
|
||||
}
|
||||
|
||||
const val a = <!EVALUATED: `-1`!>try {
|
||||
getArrayElement(intArrayOf(1, 2, 3), -1).let { "Element at given index is " + it }
|
||||
} catch (e: Exception) {
|
||||
e.cause?.message ?: "Exception without message"
|
||||
}<!>
|
||||
|
||||
const val b = <!EVALUATED: `Element at given index is 1`!>try {
|
||||
getArrayElement(intArrayOf(1, 2, 3), 0).let { "Element at given index is " + it }
|
||||
} catch (e: Exception) {
|
||||
e.cause?.message ?: "Exception without message"
|
||||
}<!>
|
||||
Reference in New Issue
Block a user