[K/N][Tests] Adjust moved codegen tests to new infra
^KT-61259
This commit is contained in:
committed by
Space Team
parent
71a834b778
commit
73032213f0
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.changingCapturedLocal
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
var log = ""
|
||||
@@ -24,7 +22,3 @@ fun box(): String {
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
+5
-10
@@ -3,11 +3,9 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.classDeclarationInsideInline
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun f() {
|
||||
fun box(): String {
|
||||
run {
|
||||
class Test1<T : Number, G>(val x: T, val y: G) {
|
||||
override fun toString() = "test1: ${x.toDouble()}"
|
||||
@@ -18,12 +16,9 @@ fun f() {
|
||||
}
|
||||
|
||||
val v = Test2(Test1(1, Test2(Test1(1, 3))))
|
||||
println(v.a)
|
||||
println(v.a.x)
|
||||
println(v.a.y)
|
||||
assertEquals("test1: 1.0", v.a.toString())
|
||||
assertEquals("1", v.a.x.toString())
|
||||
assertEquals("test2", v.a.y.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun test() {
|
||||
f()
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
test1: 1.0
|
||||
1
|
||||
test2
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.coercionToUnit
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun <T> myRun(action: () -> T): T = action()
|
||||
@@ -17,6 +15,7 @@ fun foo(n: Number, b: Boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(foo(42, false))
|
||||
fun box(): String {
|
||||
assertEquals(Unit, foo(42, false))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
kotlin.Unit
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.correctOrderFunctionReference
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class Foo(val a: String) {
|
||||
@@ -34,7 +32,3 @@ fun box(): String {
|
||||
|
||||
return if (result == "ABCEF") "OK" else "fail 2: $result"
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
@@ -3,17 +3,19 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.defaultArgs
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
class Z
|
||||
|
||||
inline fun Z.foo(x: Int = 42, y: Int = x) {
|
||||
println(y)
|
||||
sb.appendLine(y)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val z = Z()
|
||||
z.foo()
|
||||
assertEquals("42\n", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
42
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.genericFunctionReference
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class Z<T>(val x: T)
|
||||
@@ -13,7 +11,8 @@ inline fun<T, R> foo(x: T, f: (T) -> R): R {
|
||||
return f(x)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val arr = Array(1) { foo(it, ::Z) }
|
||||
println(arr[0].x)
|
||||
assertEquals(0, arr[0].x)
|
||||
return "OK"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
0
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.getClass
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo() {
|
||||
@@ -18,6 +16,7 @@ fun foo() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println("OK")
|
||||
fun box(): String {
|
||||
foo()
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline0
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -16,7 +14,8 @@ fun bar(i: Int, j: Int): Int {
|
||||
return i + foo(i, j)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar(41, 2).toString())
|
||||
fun box(): String {
|
||||
assertEquals(84, bar(41, 2))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
84
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -16,8 +14,9 @@ fun bar(s1: String, s2: String, s3: String): String {
|
||||
return s1 + foo(s2, s3)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar("Hello ", "wor", "ld"))
|
||||
fun box(): String {
|
||||
assertEquals("Hello world", bar("Hello ", "wor", "ld"))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Hello world
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline10
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -16,6 +14,7 @@ fun bar(i1: Int): Int {
|
||||
return foo(i1) { 1 }
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar(1).toString())
|
||||
fun box(): String {
|
||||
assertEquals(2, bar(1))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
2
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline11
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -16,6 +14,7 @@ fun bar(i1: Int): Boolean {
|
||||
return foo<Double>(i1)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar(1).toString())
|
||||
fun box(): String {
|
||||
assertFalse(bar(1))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline12
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -16,6 +14,7 @@ fun bar(i1: Int): Boolean {
|
||||
return foo<Double>()
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar(1).toString())
|
||||
fun box(): String {
|
||||
assertTrue(bar(1))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline13
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
open class A<T1>()
|
||||
@@ -19,6 +17,7 @@ fun bar(): Boolean {
|
||||
return foo<B<Int>>(B<Int>())
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar().toString())
|
||||
fun box(): String {
|
||||
assertTrue(bar())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
true
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline14
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -26,6 +24,7 @@ fun bar(i0: Int): Int {
|
||||
return foo1(i0) + foo3(i0)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar(2).toString())
|
||||
fun box(): String {
|
||||
assertEquals(9, bar(2))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
9
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline15
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -21,6 +19,7 @@ fun bar(i0: Int): Int {
|
||||
return foo1(i0) { foo2(it) + 1 }
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar(2).toString())
|
||||
fun box(): String {
|
||||
assertEquals(4, bar(2))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
4
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline16
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -21,6 +19,7 @@ fun bar(): Boolean {
|
||||
return result.isEmpty()
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar().toString())
|
||||
fun box(): String {
|
||||
assertFalse(bar())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
false
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline17
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -18,6 +16,7 @@ fun bar(): List<Int> {
|
||||
return foo <Int> (1, 2)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar().toString())
|
||||
fun box(): String {
|
||||
assertEquals("[1, 2]", bar().toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
[1, 2]
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline18
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -22,6 +20,7 @@ fun bar(): Boolean {
|
||||
return result
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar().toString())
|
||||
fun box(): String {
|
||||
assertTrue(bar())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
true
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline19
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -17,7 +15,8 @@ fun bar(): Int {
|
||||
return foo(1) + foo(2)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar().toString())
|
||||
fun box(): String {
|
||||
assertEquals(6, bar())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
6
|
||||
+7
-4
@@ -3,19 +3,22 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline2
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun foo(i4: Int, i5: Int) {
|
||||
println("hello $i4 $i5")
|
||||
sb.appendLine("hello $i4 $i5")
|
||||
}
|
||||
|
||||
fun bar(i1: Int, i2: Int) {
|
||||
foo(i1, i2)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
bar(1, 8)
|
||||
|
||||
assertEquals("hello 1 8\n", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
hello 1 8
|
||||
+3
-5
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline20
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -13,9 +11,9 @@ inline fun bar(block: () -> String) : String {
|
||||
}
|
||||
|
||||
fun bar2() : String {
|
||||
return bar { return "def" }
|
||||
return bar { return "OK" }
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar2())
|
||||
fun box(): String {
|
||||
return bar2()
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
def
|
||||
+16
-7
@@ -3,25 +3,34 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline21
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
inline fun foo2(block2: () -> Int) : Int {
|
||||
println("foo2")
|
||||
sb.appendLine("foo2")
|
||||
return block2()
|
||||
}
|
||||
|
||||
inline fun foo1(block1: () -> Int) : Int {
|
||||
println("foo1")
|
||||
sb.appendLine("foo1")
|
||||
return foo2(block1)
|
||||
}
|
||||
|
||||
fun bar(block: () -> Int) : Int {
|
||||
println("bar")
|
||||
sb.appendLine("bar")
|
||||
return foo1(block)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar { 33 })
|
||||
fun box(): String {
|
||||
sb.appendLine(bar { 33 })
|
||||
|
||||
assertEquals("""
|
||||
bar
|
||||
foo1
|
||||
foo2
|
||||
33
|
||||
|
||||
""".trimIndent(), sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
bar
|
||||
foo1
|
||||
foo2
|
||||
33
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline22
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
inline fun foo2(i2: Int): Int {
|
||||
@@ -19,6 +17,7 @@ fun bar(): Int {
|
||||
return foo1(11)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar().toString())
|
||||
fun box(): String {
|
||||
assertEquals(14, bar())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
14
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline23
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
inline fun <reified T> foo(i2: Any): T {
|
||||
@@ -15,6 +13,7 @@ fun bar(i1: Int): Int {
|
||||
return foo<Int>(i1)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar(33))
|
||||
fun box(): String {
|
||||
assertEquals(33, bar(33))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
33
|
||||
+15
-5
@@ -3,15 +3,25 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline24
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo() = println("foo")
|
||||
fun bar() = println("bar")
|
||||
val sb = StringBuilder()
|
||||
fun myPrintln(s: String): Unit {
|
||||
sb.appendLine(s)
|
||||
}
|
||||
|
||||
fun foo() = myPrintln("foo")
|
||||
fun bar() = myPrintln("bar")
|
||||
|
||||
inline fun baz(x: Unit = foo(), y: Unit) {}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
baz(y = bar())
|
||||
|
||||
assertEquals("""
|
||||
bar
|
||||
foo
|
||||
|
||||
""".trimIndent(), sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
bar
|
||||
foo
|
||||
+5
-5
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline25
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
inline fun foo(block: String.() -> Unit) {
|
||||
@@ -19,12 +17,14 @@ inline fun baz(block: String.() -> Unit) {
|
||||
block("Ok")
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
bar {
|
||||
println(it)
|
||||
assertEquals("Ok", it)
|
||||
}
|
||||
|
||||
baz {
|
||||
println(this)
|
||||
assertEquals("Ok", this)
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
Ok
|
||||
Ok
|
||||
+4
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline26
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
inline fun call(block1: () -> Unit, noinline block2: () -> Int): Int {
|
||||
@@ -12,7 +10,9 @@ inline fun call(block1: () -> Unit, noinline block2: () -> Int): Int {
|
||||
return block2()
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
var x = 5
|
||||
println(call({ x = 7 }, x::toInt))
|
||||
assertEquals(5, call({ x = 7 }, x::toInt))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
5
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline3
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -20,6 +18,7 @@ fun bar(i1: Int, i2: Int, i3: Int): Int {
|
||||
return i1 + foo(i2, i3)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar(1, 8, 2).toString())
|
||||
fun box(): String {
|
||||
assertEquals(5, bar(1, 8, 2))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
5
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline4
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -17,6 +15,7 @@ fun bar(i1: Int, i2: Int): Int {
|
||||
return foo(i1, i2)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar(3, 8).toString())
|
||||
fun box(): String {
|
||||
assertEquals(3, bar(3, 8))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
3
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline5
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -16,7 +14,8 @@ fun bar(i1: Int): Int {
|
||||
return foo(i1) { return 33 }
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar(1).toString())
|
||||
fun box(): String {
|
||||
assertEquals(33, bar(1))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
33
|
||||
+16
-7
@@ -3,24 +3,33 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline6
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun foo(body: () -> Unit) {
|
||||
println("hello1")
|
||||
sb.appendLine("hello1")
|
||||
body()
|
||||
println("hello4")
|
||||
sb.appendLine("hello4")
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
foo {
|
||||
println("hello2")
|
||||
println("hello3")
|
||||
sb.appendLine("hello2")
|
||||
sb.appendLine("hello3")
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
bar()
|
||||
|
||||
assertEquals("""
|
||||
hello1
|
||||
hello2
|
||||
hello3
|
||||
hello4
|
||||
|
||||
""".trimIndent(), sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
hello1
|
||||
hello2
|
||||
hello3
|
||||
hello4
|
||||
+12
-4
@@ -3,14 +3,14 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline7
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun foo(vararg args: Int) {
|
||||
for (a in args) {
|
||||
println(a.toString())
|
||||
sb.appendLine(a.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,14 @@ fun bar() {
|
||||
foo(1, 2, 3)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
bar()
|
||||
|
||||
assertEquals("""
|
||||
1
|
||||
2
|
||||
3
|
||||
|
||||
""".trimIndent(), sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
1
|
||||
2
|
||||
3
|
||||
+3
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline8
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@@ -16,6 +14,7 @@ fun bar(i1: Int, i2: Int) : Int {
|
||||
return foo(i1 + i2, 2)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar(1, 2).toString())
|
||||
fun box(): String {
|
||||
assertEquals(8, bar(1, 2))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
8
|
||||
+12
-5
@@ -3,17 +3,17 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.inline9
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun foo(i3: Int, i4: Int): Int {
|
||||
return i3 + i3 + i4
|
||||
}
|
||||
|
||||
fun quiz(i: Int) : Int {
|
||||
println("hello")
|
||||
sb.appendLine("hello")
|
||||
return i + 1
|
||||
}
|
||||
|
||||
@@ -21,6 +21,13 @@ fun bar(i1: Int, i2: Int): Int {
|
||||
return foo(quiz(i1), i2)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(bar(1, 2).toString())
|
||||
fun box(): String {
|
||||
sb.appendLine(bar(1, 2).toString())
|
||||
|
||||
assertEquals("""
|
||||
hello
|
||||
6
|
||||
|
||||
""".trimIndent(), sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
hello
|
||||
6
|
||||
@@ -3,14 +3,16 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.lambdaAsAny
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
inline fun foo(x: Any) {
|
||||
println(if (x === x) "Ok" else "Fail")
|
||||
sb.append(if (x === x) "OK" else "FAIL")
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
foo { 42 }
|
||||
|
||||
return sb.toString()
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Ok
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.lambdaInDefaultValue
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
inline fun inlineFun(param: String, lambda: (String) -> String = { it }): String {
|
||||
@@ -14,7 +12,3 @@ inline fun inlineFun(param: String, lambda: (String) -> String = { it }): String
|
||||
fun box(): String {
|
||||
return inlineFun("OK")
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(box())
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
+5
-4
@@ -3,10 +3,10 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.localFunctionInInitializerBlock
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
class Foo {
|
||||
init {
|
||||
bar()
|
||||
@@ -14,9 +14,10 @@ class Foo {
|
||||
}
|
||||
|
||||
inline fun bar() {
|
||||
println({ "Ok" }())
|
||||
sb.append({ "OK" }())
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
Foo()
|
||||
return sb.toString()
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
Ok
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.localObjectReturnedFromWhen
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo() {
|
||||
@@ -15,7 +13,7 @@ fun foo() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
foo()
|
||||
println("Ok")
|
||||
return "OK"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Ok
|
||||
@@ -3,20 +3,27 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.propertyAccessorInline
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
object C {
|
||||
const val x = 42
|
||||
}
|
||||
|
||||
fun getC(): C {
|
||||
println(123)
|
||||
sb.appendLine(123)
|
||||
return C
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(getC().x)
|
||||
fun box(): String {
|
||||
sb.appendLine(getC().x)
|
||||
|
||||
assertEquals("""
|
||||
123
|
||||
42
|
||||
|
||||
""".trimIndent(), sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
123
|
||||
42
|
||||
@@ -1,5 +1,3 @@
|
||||
package codegen.inline.redundantCoercionsCleaner
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
inline fun runAndThrow(action: () -> Unit): Nothing {
|
||||
@@ -11,39 +9,9 @@ inline fun foo(): Int = runAndThrow {
|
||||
return 1
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val result: Any = foo()
|
||||
assertEquals(1, result)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// The test below is inspired by https://youtrack.jetbrains.com/issue/KT-48876.
|
||||
|
||||
fun bar2(): Any {
|
||||
return foo2()
|
||||
}
|
||||
|
||||
inline fun foo2(): Int {
|
||||
return try {
|
||||
throw Throwable()
|
||||
} catch (e: Throwable) {
|
||||
return 2
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest2() {
|
||||
assertEquals(2, bar2())
|
||||
}
|
||||
|
||||
// Test for https://youtrack.jetbrains.com/issue/KT-49356.
|
||||
|
||||
inline fun foo3(): Int {
|
||||
return (return 3)
|
||||
}
|
||||
|
||||
fun bar3(): Any {
|
||||
return foo3()
|
||||
}
|
||||
|
||||
@Test fun runTest3() {
|
||||
assertEquals(3, bar3())
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import kotlin.test.*
|
||||
|
||||
// The test below is inspired by https://youtrack.jetbrains.com/issue/KT-48876.
|
||||
|
||||
fun bar2(): Any {
|
||||
return foo2()
|
||||
}
|
||||
|
||||
inline fun foo2(): Int {
|
||||
return try {
|
||||
throw Throwable()
|
||||
} catch (e: Throwable) {
|
||||
return 2
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(2, bar2())
|
||||
return "OK"
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import kotlin.test.*
|
||||
|
||||
// Test for https://youtrack.jetbrains.com/issue/KT-49356.
|
||||
|
||||
inline fun foo3(): Int {
|
||||
return (return 3)
|
||||
}
|
||||
|
||||
fun bar3(): Any {
|
||||
return foo3()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(3, bar3())
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,18 +3,19 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.returnLocalClassFromBlock
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
inline fun <R> call(block: ()->R): R {
|
||||
try {
|
||||
return block()
|
||||
} finally {
|
||||
println("Zzz")
|
||||
sb.append("OK")
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
call { class Z(); Z() }
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Zzz
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.statementAsLastExprInBlock
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo() {
|
||||
@@ -18,6 +16,7 @@ fun foo() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println("OK")
|
||||
fun box(): String {
|
||||
foo()
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
@@ -3,26 +3,28 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.twiceInlinedObject
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
inline fun exec(f: () -> Unit) = f()
|
||||
|
||||
inline fun test2() {
|
||||
val obj = object {
|
||||
fun sayOk() = println("Ok")
|
||||
fun sayOk() = sb.append("OK")
|
||||
}
|
||||
obj.sayOk()
|
||||
}
|
||||
|
||||
inline fun noExec(f: () -> Unit) { }
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
exec {
|
||||
test2()
|
||||
}
|
||||
noExec {
|
||||
test2()
|
||||
}
|
||||
|
||||
return sb.toString()
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
Ok
|
||||
+2
-4
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.inline.typeSubstitutionInFakeOverride
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
abstract class A {
|
||||
@@ -21,6 +19,6 @@ class B : A() {
|
||||
|
||||
class OK
|
||||
|
||||
@Test fun runTest() {
|
||||
println(B().bar())
|
||||
fun box(): String {
|
||||
return B().bar()
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
OK
|
||||
Reference in New Issue
Block a user