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
+23
View File
@@ -0,0 +1,23 @@
@CompileTimeCalculation
class A(val value: Int)
@CompileTimeCalculation
fun changeAndReturnSum(intArray: IntArray, index: Int, newValue: Int): Int {
intArray[index] = newValue
var sum = 0
for (i in intArray) sum += i
return sum
}
@CompileTimeCalculation
fun changeAndReturnSumForObject(array: Array<A>, index: Int, newValue: A): Int {
array[index] = newValue
var sum = 0
for (aObject in array) sum += aObject.value
return sum
}
const val a = arrayOf(1, 2, 3).<!EVALUATED: `3`!>size<!>
const val b = <!EVALUATED: `15`!>changeAndReturnSum(intArrayOf(1, 2, 3), 0, 10)<!>
const val c = emptyArray<Int>().<!EVALUATED: `0`!>size<!>
const val d = <!EVALUATED: `15`!>changeAndReturnSumForObject(arrayOf(A(1), A(2), A(3)), 0, A(10))<!>