Update bytecodeText and bytecodeListing tests on coroutines

This commit is contained in:
Denis Zharkov
2016-12-15 10:51:40 +03:00
committed by Stanislav Erokhin
parent 8387d04425
commit 845e116aa9
16 changed files with 116 additions and 50 deletions
@@ -1,17 +1,18 @@
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere() = suspendWithCurrentContinuation<String> { x -> suspend fun suspendHere() = suspendWithCurrentContinuation<String> { x ->
x.resume("OK") x.resume("OK")
} }
} }
fun builder(coroutine c: Controller.(String, Long) -> Continuation<Unit>) { fun builder(c: suspend Controller.() -> Unit) {
c(Controller(), "", 2L).resume(Unit)
} }
fun box(): String { fun box(): String {
var result = "" var result = ""
builder { x, y -> builder { ->
val z = "" val z = ""
val u = 1L val u = 1L
result = suspendHere() result = suspendHere()
@@ -10,18 +10,17 @@ final class CoroutineFieldsKt$box$1 {
private field J$0: long private field J$0: long
private field L$0: java.lang.Object private field L$0: java.lang.Object
private field L$1: java.lang.Object private field L$1: java.lang.Object
private field p$0: java.lang.String private field p$: Controller
private field p$1: long
inner class CoroutineFieldsKt$box$1 inner class CoroutineFieldsKt$box$1
method <init>(p0: kotlin.jvm.internal.Ref$ObjectRef): void method <init>(p0: kotlin.jvm.internal.Ref$ObjectRef, p1: kotlin.coroutines.Continuation): void
protected final method doResume(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Throwable): void protected final @org.jetbrains.annotations.Nullable method doResume(@org.jetbrains.annotations.Nullable p0: java.lang.Object, @org.jetbrains.annotations.Nullable p1: java.lang.Throwable): java.lang.Object
public final @org.jetbrains.annotations.NotNull method invoke(@org.jetbrains.annotations.NotNull p0: Controller, @org.jetbrains.annotations.NotNull p1: java.lang.String, p2: long): kotlin.coroutines.Continuation public final @org.jetbrains.annotations.Nullable method invoke(@org.jetbrains.annotations.NotNull p0: Controller, @org.jetbrains.annotations.NotNull p1: kotlin.coroutines.Continuation): java.lang.Object
public synthetic method invoke(p0: java.lang.Object, p1: java.lang.Object, p2: java.lang.Object): java.lang.Object public synthetic method invoke(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
} }
@kotlin.Metadata @kotlin.Metadata
public final class CoroutineFieldsKt { public final class CoroutineFieldsKt {
inner class CoroutineFieldsKt$box$1 inner class CoroutineFieldsKt$box$1
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
public final static method builder(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function3): void public final static method builder(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function2): void
} }
+8 -7
View File
@@ -1,10 +1,11 @@
class Controller { // WITH_RUNTIME
suspend fun suspendHere() = "" // WITH_COROUTINES
} // TREAT_AS_ONE_FILE
import kotlin.coroutines.*
suspend fun suspendHere() = ""
fun builder(c: suspend () -> Unit) {
fun builder(coroutine c: Controller.() -> Continuation<Unit>) { c.startCoroutine(EmptyContinuation)
c(Controller()).resume(Unit)
} }
fun box(): String { fun box(): String {
@@ -19,5 +20,5 @@ fun box(): String {
} }
// 1 GETSTATIC kotlin/Unit.INSTANCE : Lkotlin/Unit; // 1 GETSTATIC kotlin/Unit.INSTANCE : Lkotlin/Unit;
// 1 GETSTATIC kotlin/coroutines/Suspend.INSTANCE // 1 GETSTATIC EmptyContinuation.INSTANCE
// 2 GETSTATIC // 2 GETSTATIC
@@ -1,11 +1,17 @@
// WITH_RUNTIME
// WITH_COROUTINES
// TREAT_AS_ONE_FILE
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
SUSPENDED
} }
} }
fun builder(coroutine c: Controller.() -> Continuation<Unit>) { fun builder(c: suspend Controller.() -> Unit) {
c(Controller()).resume(Unit) c.startCoroutine(Controller(), EmptyContinuation)
} }
fun foo() = true fun foo() = true
@@ -1,11 +1,17 @@
// WITH_RUNTIME
// WITH_COROUTINES
// TREAT_AS_ONE_FILE
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
SUSPENDED
} }
} }
fun builder(coroutine c: Controller.() -> Continuation<Unit>) { fun builder(c: suspend Controller.() -> Unit) {
c(Controller()).resume(Unit) c.startCoroutine(Controller(), EmptyContinuation)
} }
private var byteResult: Byte = 0 private var byteResult: Byte = 0
@@ -1,11 +1,17 @@
// WITH_RUNTIME
// WITH_COROUTINES
// TREAT_AS_ONE_FILE
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
SUSPENDED
} }
} }
fun builder(coroutine c: Controller.() -> Continuation<Unit>) { fun builder(c: suspend Controller.() -> Unit) {
c(Controller()).resume(Unit) c.startCoroutine(Controller(), EmptyContinuation)
} }
private var booleanResult = false private var booleanResult = false
@@ -1,11 +1,17 @@
// WITH_RUNTIME
// WITH_COROUTINES
// TREAT_AS_ONE_FILE
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
SUSPENDED
} }
} }
fun builder(coroutine c: Controller.() -> Continuation<Unit>) { fun builder(c: suspend Controller.() -> Unit) {
c(Controller()).resume(Unit) c.startCoroutine(Controller(), EmptyContinuation)
} }
private var byteResult: Byte = 0 private var byteResult: Byte = 0
@@ -1,11 +1,17 @@
// WITH_RUNTIME
// WITH_COROUTINES
// TREAT_AS_ONE_FILE
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
SUSPENDED
} }
} }
fun builder(coroutine c: Controller.() -> Continuation<Unit>) { fun builder(c: suspend Controller.() -> Unit) {
c(Controller()).resume(Unit) c.startCoroutine(Controller(), EmptyContinuation)
} }
private var booleanResult = false private var booleanResult = false
@@ -1,11 +1,17 @@
// WITH_RUNTIME
// WITH_COROUTINES
// TREAT_AS_ONE_FILE
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
SUSPENDED
} }
} }
fun builder(coroutine c: Controller.() -> Continuation<Unit>) { fun builder(c: suspend Controller.() -> Unit) {
c(Controller()).resume(Unit) c.startCoroutine(Controller(), EmptyContinuation)
} }
private var result: String = "" private var result: String = ""
@@ -1,12 +1,18 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES
// TREAT_AS_ONE_FILE
// TARGET_BACKEND: JVM
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
SUSPENDED
} }
} }
fun builder(coroutine c: Controller.() -> Continuation<Unit>) { fun builder(c: suspend Controller.() -> Unit) {
c(Controller()).resume(Unit) c.startCoroutine(Controller(), EmptyContinuation)
} }
@JvmField @JvmField
@@ -1,11 +1,17 @@
// WITH_RUNTIME
// WITH_COROUTINES
// TREAT_AS_ONE_FILE
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
SUSPENDED
} }
} }
fun builder(coroutine c: Controller.() -> Continuation<Unit>) { fun builder(c: suspend Controller.() -> Unit) {
c(Controller()).resume(Unit) c.startCoroutine(Controller(), EmptyContinuation)
} }
private var booleanResult = false private var booleanResult = false
@@ -1,12 +1,18 @@
// WITH_RUNTIME // WITH_RUNTIME
// WITH_COROUTINES
// TREAT_AS_ONE_FILE
// TARGET_BACKEND: JVM
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
SUSPENDED
} }
} }
fun builder(coroutine c: Controller.() -> Continuation<Unit>) { fun builder(c: suspend Controller.() -> Unit) {
c(Controller()).resume(Unit) c.startCoroutine(Controller(), EmptyContinuation)
} }
@JvmField @JvmField
@@ -1,11 +1,17 @@
// WITH_RUNTIME
// WITH_COROUTINES
// TREAT_AS_ONE_FILE
import kotlin.coroutines.*
class Controller { class Controller {
suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x -> suspend fun suspendHere(): Unit = suspendWithCurrentContinuation { x ->
x.resume(Unit) x.resume(Unit)
SUSPENDED
} }
} }
fun builder(coroutine c: Controller.() -> Continuation<Unit>) { fun builder(c: suspend Controller.() -> Unit) {
c(Controller()).resume(Unit) c.startCoroutine(Controller(), EmptyContinuation)
} }
fun box(): String { fun box(): String {
@@ -1,11 +1,13 @@
class Controller { // WITH_RUNTIME
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> // WITH_COROUTINES
x.resume("OK") // TREAT_AS_ONE_FILE
} import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
} }
fun builder(coroutine c: Controller.() -> Continuation<Unit>) { fun builder(c: suspend () -> Unit) {
c(Controller()).resume(Unit) c.startCoroutine(EmptyContinuation)
} }
fun box(): String { fun box(): String {
@@ -1,11 +1,13 @@
class Controller { // WITH_RUNTIME
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x -> // WITH_COROUTINES
x.resume("OK") // TREAT_AS_ONE_FILE
} import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
} }
fun builder(coroutine c: Controller.() -> Continuation<Unit>) { fun builder(c: suspend () -> Unit) {
c(Controller()).resume(Unit) c.startCoroutine(EmptyContinuation)
} }
fun box(): String { fun box(): String {
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.codegen
import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.test.ConfigurationKind import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import org.jetbrains.kotlin.utils.rethrow import org.jetbrains.kotlin.utils.rethrow
import org.junit.Assert import org.junit.Assert
import java.io.File import java.io.File
@@ -33,7 +34,7 @@ abstract class AbstractBytecodeTextTest : CodegenTestCase() {
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL, files, javaFilesDir) createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL, files, javaFilesDir)
loadMultiFiles(files) loadMultiFiles(files)
if (isMultiFileTest(files)) { if (isMultiFileTest(files) && !InTextDirectivesUtils.isDirectiveDefined(wholeFile.readText(), "TREAT_AS_ONE_FILE")) {
doTestMultiFile(files) doTestMultiFile(files)
} }
else { else {