[WIP] Add Compiler Smoke Tests for (suspend) main methods
This commit ports the (parameterless) main integration tests in `CompilerSmokeTest` to the IR backend. It also includes a simple suspend main test. The advanced ones (like `helloAppSuspendParameterlessMain`) are currently blocked by pending changes to capturing suspend lambdas, which are underway.
This commit is contained in:
committed by
Ilmir Usmanov
parent
55aafb3430
commit
5b62c9e54d
@@ -0,0 +1 @@
|
||||
Return code: 0
|
||||
@@ -0,0 +1,6 @@
|
||||
package Hello
|
||||
|
||||
fun main(args: kotlin.Array<kotlin.String>) {
|
||||
args.size
|
||||
System.out.println("Hello from fully qualified main!")
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
Hello from fully qualified main!
|
||||
|
||||
Return code: 0
|
||||
@@ -0,0 +1 @@
|
||||
Return code: 0
|
||||
@@ -0,0 +1,5 @@
|
||||
package Hello
|
||||
|
||||
fun main() {
|
||||
System.out.println("Hello!")
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
Hello!
|
||||
|
||||
Return code: 0
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
Return code: 0
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package Hello
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
args.size
|
||||
System.out.println("Hello!")
|
||||
}
|
||||
|
||||
fun main() {
|
||||
System.out.println("Fail")
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
Hello!
|
||||
|
||||
Return code: 0
|
||||
+1
@@ -0,0 +1 @@
|
||||
Return code: 0
|
||||
@@ -0,0 +1,5 @@
|
||||
package Hello
|
||||
|
||||
fun main() {
|
||||
System.out.println("Hello!")
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
Hello!
|
||||
|
||||
Return code: 0
|
||||
+1
@@ -0,0 +1 @@
|
||||
Return code: 0
|
||||
@@ -0,0 +1,35 @@
|
||||
package Hello
|
||||
|
||||
import kotlin.concurrent.thread
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
@kotlin.jvm.Volatile
|
||||
private var result = ""
|
||||
@kotlin.jvm.Volatile
|
||||
private var callback: Function0<Unit>? = null
|
||||
|
||||
suspend fun appendAndSuspend(s: String) {
|
||||
result += s
|
||||
|
||||
suspendCoroutine<Unit> { continuation ->
|
||||
callback = {
|
||||
continuation.resume(Unit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun main(args: Array<String>) {
|
||||
thread(isDaemon = true) {
|
||||
while (true) {
|
||||
val c = callback
|
||||
c?.invoke()
|
||||
Thread.sleep(500)
|
||||
}
|
||||
}
|
||||
|
||||
appendAndSuspend(args[0])
|
||||
appendAndSuspend(args[1])
|
||||
println(result)
|
||||
callback = null
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
OK
|
||||
|
||||
Return code: 0
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
Return code: 0
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("Foo")
|
||||
package Hello
|
||||
|
||||
import kotlin.concurrent.thread
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
@kotlin.jvm.Volatile
|
||||
private var result = ""
|
||||
@kotlin.jvm.Volatile
|
||||
private var callback: Function0<Unit>? = null
|
||||
|
||||
suspend fun appendAndSuspend(s: String) {
|
||||
result += s
|
||||
|
||||
suspendCoroutine<Unit> { continuation ->
|
||||
callback = {
|
||||
continuation.resume(Unit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun main(args: Array<String>) {
|
||||
thread(isDaemon = true) {
|
||||
while (true) {
|
||||
val c = callback
|
||||
c?.invoke()
|
||||
Thread.sleep(500)
|
||||
}
|
||||
}
|
||||
|
||||
appendAndSuspend(args[0])
|
||||
appendAndSuspend(args[1])
|
||||
println(result)
|
||||
callback = null
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
OK
|
||||
|
||||
Return code: 0
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
Return code: 0
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package Hello
|
||||
|
||||
import kotlin.concurrent.thread
|
||||
import kotlin.coroutines.suspendCoroutine
|
||||
import kotlin.coroutines.resume
|
||||
import kotlin.reflect.jvm.javaMethod
|
||||
|
||||
@kotlin.jvm.Volatile
|
||||
private var result = ""
|
||||
@kotlin.jvm.Volatile
|
||||
private var callback: Function0<Unit>? = null
|
||||
|
||||
suspend fun appendAndSuspend(s: String) {
|
||||
result += s
|
||||
|
||||
suspendCoroutine<Unit> { continuation ->
|
||||
callback = {
|
||||
continuation.resume(Unit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun main() {
|
||||
thread(isDaemon = true) {
|
||||
while (true) {
|
||||
val c = callback
|
||||
c?.invoke()
|
||||
Thread.sleep(500)
|
||||
}
|
||||
}
|
||||
|
||||
appendAndSuspend("O")
|
||||
appendAndSuspend("K")
|
||||
println(result)
|
||||
callback = null
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
OK
|
||||
|
||||
Return code: 0
|
||||
+1
@@ -0,0 +1 @@
|
||||
Return code: 0
|
||||
@@ -0,0 +1,6 @@
|
||||
package Hello
|
||||
|
||||
fun main(vararg args: kotlin.String) {
|
||||
args.size
|
||||
System.out.println("Hello from vararg main!")
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
Hello from vararg main!
|
||||
|
||||
Return code: 0
|
||||
+1
@@ -0,0 +1 @@
|
||||
Return code: 0
|
||||
@@ -0,0 +1,10 @@
|
||||
package Hello
|
||||
|
||||
suspend fun f(o: String, k: String): String {
|
||||
return o + k
|
||||
}
|
||||
|
||||
suspend fun main(args: Array<String>) {
|
||||
val result = f(args[0], args[1])
|
||||
println(result)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
OK
|
||||
|
||||
Return code: 0
|
||||
Reference in New Issue
Block a user