TESTS: New tests added
This commit is contained in:
@@ -1232,6 +1232,21 @@ task inline14(type: RunKonanTest) {
|
||||
source = "codegen/inline/inline14.kt"
|
||||
}
|
||||
|
||||
task inline15(type: RunKonanTest) {
|
||||
goldValue = "4\n"
|
||||
source = "codegen/inline/inline15.kt"
|
||||
}
|
||||
|
||||
//task inline16(type: RunKonanTest) {
|
||||
// goldValue = "false\n"
|
||||
// source = "codegen/inline/inline16.kt"
|
||||
//}
|
||||
|
||||
task inline17(type: RunKonanTest) {
|
||||
goldValue = "[1, 2]\n"
|
||||
source = "codegen/inline/inline17.kt"
|
||||
}
|
||||
|
||||
kotlinNativeInterop {
|
||||
sysstat {
|
||||
pkg 'sysstat'
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun foo2(i1: Int): Int {
|
||||
return i1 + 1
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun foo1(i1: Int, body: (Int) -> Int): Int {
|
||||
return body(i1)
|
||||
}
|
||||
|
||||
fun bar(i0: Int): Int {
|
||||
return foo1(i0) { foo2(it) + 1 }
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println(bar(2).toString())
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun <T, C : MutableCollection<in T>> foo(destination: C, predicate: (T) -> Boolean): C {
|
||||
for (element in destination) {
|
||||
val value = element as T
|
||||
if (!predicate(value)) destination.add(value)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
fun bar(): Boolean {
|
||||
val result = foo <Int, MutableList<Int>> (mutableListOf(1, 2, 3)) { true }
|
||||
return result.isEmpty()
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println(bar().toString())
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun <T> foo(i1: T, i2: T): List<T> {
|
||||
return listOf(i1, i2)
|
||||
}
|
||||
|
||||
fun bar(): List<Int> {
|
||||
return foo <Int> (1, 2)
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println(bar().toString())
|
||||
}
|
||||
Reference in New Issue
Block a user