Test framework for inline
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
fun test1(): Int {
|
||||
var s = 0;
|
||||
2.times2 {
|
||||
s++
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (test1() != 2) return "test1: ${test1()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
public inline fun Int.times2(body : () -> Unit) {
|
||||
var count = this;
|
||||
while (count > 0) {
|
||||
body()
|
||||
count--
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user