Add ir interpreter tests

This commit is contained in:
Ivan Kylchik
2021-05-19 16:27:03 +03:00
committed by TeamCityServer
parent cc2d7340dc
commit e28ab45c51
115 changed files with 5104 additions and 0 deletions
@@ -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"
}<!>