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,12 @@
@CompileTimeCalculation
class MyCharSequence(val str: String): CharSequence {
override val length: Int = str.length
override fun get(index: Int) = str[index]
override fun subSequence(startIndex: Int, endIndex: Int) = str.subSequence(startIndex, endIndex)
}
const val sbSize = StringBuilder(MyCharSequence("MyString")).<!EVALUATED: `8`!>length<!>
const val appendSize = StringBuilder().append(MyCharSequence("MyString")).<!EVALUATED: `8`!>length<!>
const val subSequenceSize = StringBuilder(StringBuilder(MyCharSequence("MyString")).subSequence(0, 4)).<!EVALUATED: `4`!>length<!>
+13
View File
@@ -0,0 +1,13 @@
import kotlin.collections.*
@CompileTimeCalculation
class B(val b: Int) {
override fun equals(other: Any?): Boolean {
other as? B ?: return false
return this.b == other.b
}
override fun toString(): String = "B($b)"
}
const val areEquals = <!EVALUATED: `true`!>listOf(B(1), B(2)) == listOf(B(1), B(2))<!>
const val asString = listOf(B(1), B(2)).<!EVALUATED: `[B(1), B(2)]`!>toString()<!>
+8
View File
@@ -0,0 +1,8 @@
import kotlin.*
import kotlin.collections.*
@CompileTimeCalculation
class A(val a: Int)
const val size = mapOf(1 to "A(1)").<!EVALUATED: `1`!>size<!>
const val first = mapOf(1 to "A(1)").entries.single().<!EVALUATED: `1`!>key<!>
const val second = mapOf(1 to "A(1)").values.<!EVALUATED: `A(1)`!>single()<!>
+21
View File
@@ -0,0 +1,21 @@
import kotlin.collections.*
@CompileTimeCalculation
class MyArrayList<E>: ArrayList<E>() {
var addCounter = 0
override fun add(element: E): Boolean {
addCounter++
return super.add(element)
}
}
@CompileTimeCalculation
fun test(): String {
val list = MyArrayList<Int>()
list.add(1)
list.add(2)
list.add(3)
return "Counter " + list.addCounter + "; size " + list.size
}
const val testResult = <!EVALUATED: `Counter 3; size 3`!>test()<!>