Add ir interpreter tests
This commit is contained in:
committed by
TeamCityServer
parent
cc2d7340dc
commit
e28ab45c51
@@ -0,0 +1,37 @@
|
||||
import kotlin.collections.*
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun testAdd(mutableList: MutableList<Int>, newElem: Int): String {
|
||||
mutableList.add(newElem)
|
||||
return "After add new size is " + mutableList.size
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun <T> testRemove(mutableList: MutableList<T>, toRemove: T): String {
|
||||
mutableList.remove(toRemove)
|
||||
return "After remove new size is " + mutableList.size
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun testAddAll(mutableList: MutableList<Double>, toAdd: List<Double>): String {
|
||||
mutableList.addAll(toAdd)
|
||||
return "After addAll new size is " + mutableList.size
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun testIterator(mutableList: MutableList<Byte>): String {
|
||||
var sum = 0
|
||||
for (byte in mutableList) {
|
||||
sum += byte
|
||||
}
|
||||
return "Sum = " + sum
|
||||
}
|
||||
|
||||
const val emptyMutableListSize = mutableListOf<Any>().<!EVALUATED: `0`!>size<!>
|
||||
const val mutableListSize = mutableListOf(1, 2, 3).<!EVALUATED: `3`!>size<!>
|
||||
const val mutableListAdd = <!EVALUATED: `After add new size is 4`!>testAdd(mutableListOf(1, 2, 3), 4)<!>
|
||||
const val mutableListRemove1 = <!EVALUATED: `After remove new size is 2`!>testRemove(mutableListOf("1", "2", "3"), "1")<!>
|
||||
const val mutableListRemove2 = <!EVALUATED: `After remove new size is 3`!>testRemove(mutableListOf("1", "2", "3"), "4")<!>
|
||||
const val mutableListAddAll = <!EVALUATED: `After addAll new size is 5`!>testAddAll(mutableListOf(1.0, 2.0, 3.0), listOf(4.333, -5.5))<!>
|
||||
const val mutableListSum = <!EVALUATED: `Sum = 136`!>testIterator(mutableListOf<Byte>(1, (-2).toByte(), 127, 10, 0))<!>
|
||||
const val mutableListSubList = mutableListOf(1, 2, 3, 4).subList(0, 2).<!EVALUATED: `2`!>size<!>
|
||||
Reference in New Issue
Block a user