Add ir interpreter tests
This commit is contained in:
committed by
TeamCityServer
parent
cc2d7340dc
commit
e28ab45c51
+37
@@ -0,0 +1,37 @@
|
||||
@CompileTimeCalculation
|
||||
abstract class BaseIterator(var baseStart: Int) {
|
||||
fun baseNext(): Int {
|
||||
baseStart += 1
|
||||
return base()
|
||||
}
|
||||
|
||||
abstract fun base(): Int
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
abstract class ComplexIterator(var complexStart: Int) : BaseIterator(complexStart) {
|
||||
fun complexNext() = abstractCall()
|
||||
|
||||
private fun abstractCall(): Int {
|
||||
complexStart *= 2
|
||||
return complex() + baseNext()
|
||||
}
|
||||
|
||||
abstract fun complex(): Int
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
class ImplementIterator constructor(val i: Int) : ComplexIterator(i) {
|
||||
override fun complex(): Int {
|
||||
return complexStart
|
||||
}
|
||||
|
||||
override fun base(): Int {
|
||||
return baseStart
|
||||
}
|
||||
}
|
||||
|
||||
@CompileTimeCalculation
|
||||
fun getIterator(i: Int): ComplexIterator = ImplementIterator(i)
|
||||
|
||||
const val next = getIterator(10).<!EVALUATED: `31`!>complexNext()<!>
|
||||
Reference in New Issue
Block a user