Migrate boxInline tests to new multi-file framework
This commit is contained in:
committed by
Alexander Udalov
parent
fa1f7d988e
commit
cc84aabdcf
@@ -1,18 +0,0 @@
|
||||
package test
|
||||
|
||||
inline fun inline(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
|
||||
class InlineAll {
|
||||
|
||||
inline fun inline(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
|
||||
companion object {
|
||||
inline fun inline(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
-1
@@ -1,3 +1,26 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun inline(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
|
||||
class InlineAll {
|
||||
|
||||
inline fun inline(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
|
||||
companion object {
|
||||
inline fun inline(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun testClassObjectCall(): String {
|
||||
@@ -18,4 +41,4 @@ fun box(): String {
|
||||
if (testInstanceCall() != "instance") return "test2: ${testInstanceCall()}"
|
||||
if (testPackageCall() != "package") return "test3: ${testPackageCall()}"
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
inline fun Inline.calcExt(s: (Int) -> Int, p: Int) : Int {
|
||||
return s(p)
|
||||
}
|
||||
|
||||
inline fun Inline.calcExt2(s: Int.() -> Int, p: Int) : Int {
|
||||
return p.s()
|
||||
}
|
||||
|
||||
class InlineX(val value : Int) {}
|
||||
|
||||
class Inline(val res: Int) {
|
||||
|
||||
inline fun InlineX.calcInt(s: (Int, Int) -> Int) : Int {
|
||||
return s(res, this.value)
|
||||
}
|
||||
|
||||
inline fun Double.calcDouble(s: (Int, Double) -> Double) : Double {
|
||||
return s(res, this)
|
||||
}
|
||||
|
||||
fun doWork(l : InlineX) : Int {
|
||||
return l.calcInt({ a: Int, b: Int -> a + b})
|
||||
}
|
||||
|
||||
fun doWorkWithDouble(s : Double) : Double {
|
||||
return s.calcDouble({ a: Int, b: Double -> a + b})
|
||||
}
|
||||
|
||||
}
|
||||
+35
-1
@@ -1,3 +1,37 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
inline fun Inline.calcExt(s: (Int) -> Int, p: Int) : Int {
|
||||
return s(p)
|
||||
}
|
||||
|
||||
inline fun Inline.calcExt2(s: Int.() -> Int, p: Int) : Int {
|
||||
return p.s()
|
||||
}
|
||||
|
||||
class InlineX(val value : Int) {}
|
||||
|
||||
class Inline(val res: Int) {
|
||||
|
||||
inline fun InlineX.calcInt(s: (Int, Int) -> Int) : Int {
|
||||
return s(res, this.value)
|
||||
}
|
||||
|
||||
inline fun Double.calcDouble(s: (Int, Double) -> Double) : Double {
|
||||
return s(res, this)
|
||||
}
|
||||
|
||||
fun doWork(l : InlineX) : Int {
|
||||
return l.calcInt({ a: Int, b: Int -> a + b})
|
||||
}
|
||||
|
||||
fun doWorkWithDouble(s : Double) : Double {
|
||||
return s.calcDouble({ a: Int, b: Double -> a + b})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
fun test1(): Int {
|
||||
val inlineX = Inline(9)
|
||||
return inlineX.calcExt({ z: Int -> z}, 25)
|
||||
@@ -34,4 +68,4 @@ fun box(): String {
|
||||
if (test5() != 20.0) return "test5: ${test5()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
package test
|
||||
|
||||
inline fun <T> String.test(default: T, cb: String.(T) -> T): T = cb(default)
|
||||
+9
-1
@@ -1,3 +1,11 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun <T> String.test(default: T, cb: String.(T) -> T): T = cb(default)
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
@@ -6,4 +14,4 @@ fun box(): String {
|
||||
}
|
||||
|
||||
return if (p == 50.0) "OK" else "fail $p"
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
class Inline() {
|
||||
|
||||
inline fun foo1Int(s : (l: Int) -> Int, param: Int) : Int {
|
||||
return s(param)
|
||||
}
|
||||
|
||||
inline fun foo1Double(param: Double, s : (l: Double) -> Double) : Double {
|
||||
return s(param)
|
||||
}
|
||||
|
||||
inline fun foo2Param(param1: Double, s : (i: Int, l: Double) -> Double, param2: Int) : Double {
|
||||
return s(param2, param1)
|
||||
}
|
||||
}
|
||||
|
||||
+19
-1
@@ -1,3 +1,21 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
class Inline() {
|
||||
|
||||
inline fun foo1Int(s : (l: Int) -> Int, param: Int) : Int {
|
||||
return s(param)
|
||||
}
|
||||
|
||||
inline fun foo1Double(param: Double, s : (l: Double) -> Double) : Double {
|
||||
return s(param)
|
||||
}
|
||||
|
||||
inline fun foo2Param(param1: Double, s : (i: Int, l: Double) -> Double, param2: Int) : Double {
|
||||
return s(param2, param1)
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
fun test1(): Int {
|
||||
val inlineX = Inline()
|
||||
@@ -29,4 +47,4 @@ fun box(): String {
|
||||
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
val s = doWork({11})
|
||||
|
||||
fun box(): String {
|
||||
if (s != 11) return "test1: ${s}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package test
|
||||
|
||||
|
||||
inline fun <R> doWork(crossinline job: ()-> R) : R {
|
||||
return notInline({job()})
|
||||
}
|
||||
|
||||
fun <R> notInline(job: ()-> R) : R {
|
||||
return job()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
|
||||
inline fun <R> doWork(crossinline job: ()-> R) : R {
|
||||
return notInline({job()})
|
||||
}
|
||||
|
||||
fun <R> notInline(job: ()-> R) : R {
|
||||
return job()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
val s = doWork({11})
|
||||
|
||||
fun box(): String {
|
||||
if (s != 11) return "test1: ${s}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
W("OK").safe {
|
||||
result = this as String
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package test
|
||||
|
||||
class W(val value: Any)
|
||||
|
||||
inline fun W.safe(body : Any.() -> Unit) {
|
||||
this.value?.body()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class W(val value: Any)
|
||||
|
||||
inline fun W.safe(body : Any.() -> Unit) {
|
||||
this.value?.body()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
W("OK").safe {
|
||||
result = this as String
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
class Inline() {
|
||||
|
||||
inline fun foo1(closure1 : (l: Int) -> Int, param1: Int, closure2 : (l: Double) -> Double, param2: Double) : Double {
|
||||
return closure1(param1) + closure2(param2)
|
||||
}
|
||||
|
||||
inline fun foo2(closure1 : (Int, Int) -> Int, param1: Int, closure2 : (Double, Int, Int) -> Double, param2: Double, param3: Int) : Double {
|
||||
return closure1(param1, param3) + closure2(param2, param1, param3)
|
||||
}
|
||||
}
|
||||
|
||||
+16
-1
@@ -1,3 +1,18 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
class Inline() {
|
||||
|
||||
inline fun foo1(closure1 : (l: Int) -> Int, param1: Int, closure2 : (l: Double) -> Double, param2: Double) : Double {
|
||||
return closure1(param1) + closure2(param2)
|
||||
}
|
||||
|
||||
inline fun foo2(closure1 : (Int, Int) -> Int, param1: Int, closure2 : (Double, Int, Int) -> Double, param2: Double, param3: Int) : Double {
|
||||
return closure1(param1, param3) + closure2(param2, param1, param3)
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
fun test1(): Double {
|
||||
val inlineX = Inline()
|
||||
return inlineX.foo1({ z: Int -> z}, 25, { z: Double -> z}, 11.5)
|
||||
@@ -20,4 +35,4 @@ fun box(): String {
|
||||
if (test2() != 65.5) return "test2: ${test2()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fun box(): String {
|
||||
val result = runTest{minByTest<Int> { it }}
|
||||
|
||||
if (result != 1) return "test1: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+11
@@ -1,3 +1,5 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
public inline fun <R> runTest(f: () -> R): R {
|
||||
return f()
|
||||
}
|
||||
@@ -8,3 +10,12 @@ public inline fun <R> minByTest(f: (Int) -> R): R {
|
||||
return v
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
fun box(): String {
|
||||
val result = runTest{minByTest<Int> { it }}
|
||||
|
||||
if (result != 1) return "test1: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
class InlineDouble(val res : Double) {
|
||||
|
||||
inline fun foo(s : () -> Double) : Double {
|
||||
val f = "fooStart"
|
||||
val z = s()
|
||||
return z
|
||||
}
|
||||
|
||||
inline fun foo11(s : (l: Double) -> Double) : Double {
|
||||
return s(11.0)
|
||||
}
|
||||
|
||||
inline fun fooRes(s : (l: Double) -> Double) : Double {
|
||||
val z = s(res)
|
||||
return z
|
||||
}
|
||||
|
||||
inline fun fooRes2(s : (l: Double, t: Double) -> Double) : Double {
|
||||
val f = "fooRes2Start"
|
||||
val z = s(1.0, 11.0)
|
||||
return z
|
||||
}
|
||||
}
|
||||
+28
@@ -1,3 +1,31 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
class InlineDouble(val res : Double) {
|
||||
|
||||
inline fun foo(s : () -> Double) : Double {
|
||||
val f = "fooStart"
|
||||
val z = s()
|
||||
return z
|
||||
}
|
||||
|
||||
inline fun foo11(s : (l: Double) -> Double) : Double {
|
||||
return s(11.0)
|
||||
}
|
||||
|
||||
inline fun fooRes(s : (l: Double) -> Double) : Double {
|
||||
val z = s(res)
|
||||
return z
|
||||
}
|
||||
|
||||
inline fun fooRes2(s : (l: Double, t: Double) -> Double) : Double {
|
||||
val f = "fooRes2Start"
|
||||
val z = s(1.0, 11.0)
|
||||
return z
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
fun test0Param(): Double {
|
||||
val inlineX = InlineDouble(10.0)
|
||||
return inlineX.foo({ -> 1.0})
|
||||
@@ -1,10 +0,0 @@
|
||||
package test
|
||||
|
||||
enum class MyEnum {
|
||||
K;
|
||||
|
||||
//TODO: KT-4693
|
||||
inline fun <T> doSmth(a: T) : String {
|
||||
return a.toString() + K.name
|
||||
}
|
||||
}
|
||||
+16
-1
@@ -1,3 +1,18 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
enum class MyEnum {
|
||||
K;
|
||||
|
||||
//TODO: KT-4693
|
||||
inline fun <T> doSmth(a: T) : String {
|
||||
return a.toString() + K.name
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun test1(): String {
|
||||
@@ -9,4 +24,4 @@ fun box(): String {
|
||||
if (result != "OK") return "fail1: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package test
|
||||
|
||||
inline fun <T> doSmth(a: T) : String {
|
||||
return a.toString()
|
||||
}
|
||||
+11
-1
@@ -1,3 +1,13 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun <T> doSmth(a: T) : String {
|
||||
return a.toString()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun test1(s: Long): String {
|
||||
@@ -9,4 +19,4 @@ fun box(): String {
|
||||
if (result != "11") return "fail1: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
class Inline(val res : Int) {
|
||||
|
||||
inline fun foo(s : () -> Int) : Int {
|
||||
val f = "fooStart"
|
||||
val z = s()
|
||||
return z
|
||||
}
|
||||
|
||||
inline fun foo11(s : (l: Int) -> Int) : Int {
|
||||
return s(11)
|
||||
}
|
||||
|
||||
inline fun fooRes(s : (l: Int) -> Int) : Int {
|
||||
val z = s(res)
|
||||
return z
|
||||
}
|
||||
|
||||
inline fun fooRes2(s : (l: Int, t: Int) -> Int) : Int {
|
||||
val f = "fooRes2Start"
|
||||
val z = s(1, 11)
|
||||
return z
|
||||
}
|
||||
}
|
||||
|
||||
+29
-1
@@ -1,3 +1,31 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
class Inline(val res : Int) {
|
||||
|
||||
inline fun foo(s : () -> Int) : Int {
|
||||
val f = "fooStart"
|
||||
val z = s()
|
||||
return z
|
||||
}
|
||||
|
||||
inline fun foo11(s : (l: Int) -> Int) : Int {
|
||||
return s(11)
|
||||
}
|
||||
|
||||
inline fun fooRes(s : (l: Int) -> Int) : Int {
|
||||
val z = s(res)
|
||||
return z
|
||||
}
|
||||
|
||||
inline fun fooRes2(s : (l: Int, t: Int) -> Int) : Int {
|
||||
val f = "fooRes2Start"
|
||||
val z = s(1, 11)
|
||||
return z
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
fun test0Param(): Int {
|
||||
val inlineX = Inline(10)
|
||||
return inlineX.foo({ -> 1})
|
||||
@@ -45,4 +73,4 @@ fun box(): String {
|
||||
if (test2Params() != 35) return "test2Params: ${test2Params()}"
|
||||
if (test2ParamsWithCaptured() != 19) return "test2ParamsWithCaptured: ${test2ParamsWithCaptured()}"
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package test
|
||||
|
||||
public class Data()
|
||||
|
||||
public inline fun <T, R> T.use(block: (T)-> R) : R {
|
||||
return block(this)
|
||||
}
|
||||
|
||||
public inline fun use2() : Int {
|
||||
val s = 100
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
+17
@@ -1,3 +1,20 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
public class Data()
|
||||
|
||||
public inline fun <T, R> T.use(block: (T)-> R) : R {
|
||||
return block(this)
|
||||
}
|
||||
|
||||
public inline fun use2() : Int {
|
||||
val s = 100
|
||||
return s
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
class Z {}
|
||||
@@ -1,24 +0,0 @@
|
||||
class InlineString(val res : String) {
|
||||
|
||||
inline fun foo(s : () -> String) : String {
|
||||
val f = "fooStart"
|
||||
val z = s()
|
||||
return z
|
||||
}
|
||||
|
||||
inline fun foo11(s : (l: String) -> String) : String {
|
||||
return s("11")
|
||||
}
|
||||
|
||||
inline fun fooRes(s : (l: String) -> String) : String {
|
||||
val z = s(res)
|
||||
return z
|
||||
}
|
||||
|
||||
inline fun fooRes2(s : (l: String, t: String) -> String) : String {
|
||||
val f = "fooRes2Start"
|
||||
val z = s("1", "11")
|
||||
return z
|
||||
}
|
||||
}
|
||||
|
||||
+29
-1
@@ -1,3 +1,31 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
class InlineString(val res : String) {
|
||||
|
||||
inline fun foo(s : () -> String) : String {
|
||||
val f = "fooStart"
|
||||
val z = s()
|
||||
return z
|
||||
}
|
||||
|
||||
inline fun foo11(s : (l: String) -> String) : String {
|
||||
return s("11")
|
||||
}
|
||||
|
||||
inline fun fooRes(s : (l: String) -> String) : String {
|
||||
val z = s(res)
|
||||
return z
|
||||
}
|
||||
|
||||
inline fun fooRes2(s : (l: String, t: String) -> String) : String {
|
||||
val f = "fooRes2Start"
|
||||
val z = s("1", "11")
|
||||
return z
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
fun test0Param(): String {
|
||||
val inlineX = InlineString("10")
|
||||
return inlineX.foo({ -> "1"})
|
||||
@@ -46,4 +74,4 @@ fun box(): String {
|
||||
if (test2ParamsWithCaptured() != "91") return "test2ParamsWithCaptured: ${test2ParamsWithCaptured()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package test
|
||||
|
||||
inline fun doSmth(vararg a: String) : String {
|
||||
return a.foldRight("", { a, b -> a + b})
|
||||
}
|
||||
+11
-1
@@ -1,3 +1,13 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun doSmth(vararg a: String) : String {
|
||||
return a.foldRight("", { a, b -> a + b})
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun test1(): String {
|
||||
@@ -9,4 +19,4 @@ fun box(): String {
|
||||
if (result != "OK") return "fail1: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user