Test framework for inline

This commit is contained in:
Mikhael Bogdanov
2014-02-18 12:14:06 +04:00
parent 769b07fbc8
commit 4f5b20a8db
93 changed files with 2593 additions and 8 deletions
@@ -0,0 +1,25 @@
import test.*
fun Data.test1(d: Data) : Long {
val input = Input(this)
var result = 10.toLong()
with(input) {
result = use<Long>{
val output = Output(d)
useNoInline<Long>{
data()
copyTo(output, 10)
}
}
}
return result
}
fun box(): String {
val result = Data().test1(Data())
if (result != 100.toLong()) return "test1: ${result}"
return "OK"
}
@@ -0,0 +1,27 @@
package test
public class Data()
public class Input(val d: Data) : Closeable {
public fun data() : Int = 100
}
public class Output(val d: Data) : Closeable {
public fun doOutput(data: Int): Int = data
}
public open trait Closeable {
open public fun close() {}
}
public inline fun <R> use(block: ()-> R) : R {
return block()
}
public fun <R> useNoInline(block: ()-> R) : R {
return block()
}
public fun Input.copyTo(output: Output, size: Int): Long {
return output.doOutput(this.data()).toLong()
}