Migrate boxInline tests to new multi-file framework
This commit is contained in:
committed by
Alexander Udalov
parent
fa1f7d988e
commit
cc84aabdcf
@@ -1,5 +0,0 @@
|
||||
package test
|
||||
|
||||
inline fun <T> doSmth(a: T) : Boolean {
|
||||
return a === a
|
||||
}
|
||||
+11
-1
@@ -1,3 +1,13 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun <T> doSmth(a: T) : Boolean {
|
||||
return a === a
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun test1(s: Long): Boolean {
|
||||
@@ -20,4 +30,4 @@ fun box(): String {
|
||||
if (!test3(11111.3)) return "fail 3.3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package test
|
||||
|
||||
inline fun <T> runIf(f: (T) -> T, start: T, stop: T, secondStart: T) : T {
|
||||
if (f(start) == stop) {
|
||||
return f(start)
|
||||
}
|
||||
return f(secondStart)
|
||||
}
|
||||
|
||||
|
||||
inline fun <T> runIf2(f: (T) -> T, start: T, stop: T, secondStart: T) : T {
|
||||
val result = f(start)
|
||||
if (result == stop) {
|
||||
return result
|
||||
}
|
||||
return f(secondStart)
|
||||
}
|
||||
|
||||
inline fun <T> runIfElse(f: (T) -> T, start: T, stop: T, secondStart: T) : T {
|
||||
if (f(start) == stop) {
|
||||
return f(start)
|
||||
} else {
|
||||
return f(secondStart)
|
||||
}
|
||||
}
|
||||
+31
-1
@@ -1,3 +1,33 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun <T> runIf(f: (T) -> T, start: T, stop: T, secondStart: T) : T {
|
||||
if (f(start) == stop) {
|
||||
return f(start)
|
||||
}
|
||||
return f(secondStart)
|
||||
}
|
||||
|
||||
|
||||
inline fun <T> runIf2(f: (T) -> T, start: T, stop: T, secondStart: T) : T {
|
||||
val result = f(start)
|
||||
if (result == stop) {
|
||||
return result
|
||||
}
|
||||
return f(secondStart)
|
||||
}
|
||||
|
||||
inline fun <T> runIfElse(f: (T) -> T, start: T, stop: T, secondStart: T) : T {
|
||||
if (f(start) == stop) {
|
||||
return f(start)
|
||||
} else {
|
||||
return f(secondStart)
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun testIf(): String {
|
||||
@@ -40,4 +70,4 @@ fun box(): String {
|
||||
if (result != "OK") return "fail2: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
public inline fun Int.times2(body : () -> Unit) {
|
||||
var count = this;
|
||||
while (count > 0) {
|
||||
body()
|
||||
count--
|
||||
}
|
||||
}
|
||||
+13
-1
@@ -1,3 +1,15 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
public inline fun Int.times2(body : () -> Unit) {
|
||||
var count = this;
|
||||
while (count > 0) {
|
||||
body()
|
||||
count--
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
fun test1(): Int {
|
||||
var s = 0;
|
||||
2.times2 {
|
||||
@@ -10,4 +22,4 @@ fun box(): String {
|
||||
if (test1() != 2) return "test1: ${test1()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
fun test1(): String {
|
||||
val inlineX = My()
|
||||
var d = "";
|
||||
inlineX.doWork({ z: String -> d = z; z})
|
||||
return d
|
||||
}
|
||||
|
||||
fun test2(): Int {
|
||||
val inlineX = My()
|
||||
return inlineX.perform({ z: My -> 11})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (test1() != "OK") return "test1: ${test1()}"
|
||||
if (test2() != 11) return "test1: ${test2()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
class My
|
||||
|
||||
inline fun <T, R> T.perform(job: (T)-> R) : R {
|
||||
return job(this)
|
||||
}
|
||||
|
||||
|
||||
inline fun My.someWork(job: (String) -> Any): Unit {
|
||||
this.perform {
|
||||
job("OK")
|
||||
}
|
||||
}
|
||||
|
||||
inline fun My.doWork (closure : (param : String) -> Unit) : Unit {
|
||||
this.someWork(closure)
|
||||
}
|
||||
|
||||
inline fun My.doPerform (closure : (param : My) -> Int) : Int {
|
||||
return perform(closure)
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
class My
|
||||
|
||||
inline fun <T, R> T.perform(job: (T)-> R) : R {
|
||||
return job(this)
|
||||
}
|
||||
|
||||
|
||||
inline fun My.someWork(job: (String) -> Any): Unit {
|
||||
this.perform {
|
||||
job("OK")
|
||||
}
|
||||
}
|
||||
|
||||
inline fun My.doWork (closure : (param : String) -> Unit) : Unit {
|
||||
this.someWork(closure)
|
||||
}
|
||||
|
||||
inline fun My.doPerform (closure : (param : My) -> Int) : Int {
|
||||
return perform(closure)
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
fun test1(): String {
|
||||
val inlineX = My()
|
||||
var d = "";
|
||||
inlineX.doWork({ z: String -> d = z; z})
|
||||
return d
|
||||
}
|
||||
|
||||
fun test2(): Int {
|
||||
val inlineX = My()
|
||||
return inlineX.perform({ z: My -> 11})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (test1() != "OK") return "test1: ${test1()}"
|
||||
if (test2() != 11) return "test1: ${test2()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package test
|
||||
|
||||
public class Z(public var s: Int)
|
||||
|
||||
operator inline fun Z.plusAssign(lambda: () -> Int) {
|
||||
this.s += lambda()
|
||||
}
|
||||
+13
-1
@@ -1,3 +1,15 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
public class Z(public var s: Int)
|
||||
|
||||
operator inline fun Z.plusAssign(lambda: () -> Int) {
|
||||
this.s += lambda()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun test1(s: Int): Int {
|
||||
@@ -11,4 +23,4 @@ fun box(): String {
|
||||
if (result != 22) return "fail1: ${result}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
mfun{ "".toLowerCase2() }
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package test
|
||||
|
||||
inline fun <R> mfun(f: () -> R) {
|
||||
f()
|
||||
f()
|
||||
}
|
||||
|
||||
public inline fun String.toLowerCase2() : String = ""
|
||||
@@ -0,0 +1,19 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun <R> mfun(f: () -> R) {
|
||||
f()
|
||||
f()
|
||||
}
|
||||
|
||||
public inline fun String.toLowerCase2() : String = ""
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
mfun{ "".toLowerCase2() }
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user