Added inline tests for jvm 8 target

This commit is contained in:
Mikhael Bogdanov
2017-01-24 16:45:50 +01:00
parent 32f1ce7551
commit 11578c602e
3 changed files with 39 additions and 0 deletions
@@ -0,0 +1,19 @@
// JVM_TARGET: 1.8
//WITH_RUNTIME
// FILE: 1.kt
package test
public inline fun <T, R> Iterable<T>.fold2(initial: R, operation: (R, T) -> R): R {
var accumulator = initial
for (element in this) accumulator = operation(accumulator, element)
return accumulator
}
// FILE: 2.kt
import test.*
fun box(): String {
val list = listOf("O", "K")
return list.fold2("") {a, b -> a +b}
}
@@ -0,0 +1,8 @@
// JVM_TARGET: 1.8
//WITH_RUNTIME
fun box(): String {
val list = listOf("O", "K")
return list.fold("") {a, b -> a +b}
}