Fix some of the bytecodeText tests
The changes are necessary because of release coroutines support: - Get rid of suspendCoroutineOrReturn calls. It's anyway irrelevant to what is being tested here - In varValueConflictsWithTable.kt, variables slots have been shifted because the variable for continuation's exception was removed - In varValueConflictsWithTableSameSort.kt, a variable has been introduced to preserve the same slot numbers for old variables. Otherwise, they become shifted and to the second slot, and there are a lot of irrelevant "ALOAD 2" instructions This change is another example of why bytecode text tests are evil
This commit is contained in:
@@ -185,9 +185,16 @@ public class ClassFileFactory implements OutputFileCollection {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@TestOnly
|
@TestOnly
|
||||||
public String createText() {
|
public String createText() {
|
||||||
|
return createText(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@TestOnly
|
||||||
|
public String createText(@Nullable String ignorePrefixPath) {
|
||||||
StringBuilder answer = new StringBuilder();
|
StringBuilder answer = new StringBuilder();
|
||||||
|
|
||||||
for (OutputFile file : asList()) {
|
for (OutputFile file : asList()) {
|
||||||
|
if (ignorePrefixPath != null && file.getRelativePath().startsWith(ignorePrefixPath)) continue;
|
||||||
File relativePath = new File(file.getRelativePath());
|
File relativePath = new File(file.getRelativePath());
|
||||||
answer.append("@").append(relativePath).append('\n');
|
answer.append("@").append(relativePath).append('\n');
|
||||||
switch (FilesKt.getExtension(relativePath)) {
|
switch (FilesKt.getExtension(relativePath)) {
|
||||||
|
|||||||
@@ -24,5 +24,4 @@ fun box(): String {
|
|||||||
|
|
||||||
// 2 GETSTATIC kotlin/Unit.INSTANCE
|
// 2 GETSTATIC kotlin/Unit.INSTANCE
|
||||||
// 1 GETSTATIC helpers/EmptyContinuation.Companion
|
// 1 GETSTATIC helpers/EmptyContinuation.Companion
|
||||||
// 4 GETSTATIC kotlin\/coroutines\/experimental\/EmptyCoroutineContext.INSTANCE
|
// 3 GETSTATIC
|
||||||
// 7 GETSTATIC
|
|
||||||
|
|||||||
+6
-6
@@ -1,10 +1,10 @@
|
|||||||
|
// LANGUAGE_VERSION: 1.3
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// COMMON_COROUTINES_TEST
|
|
||||||
// WITH_COROUTINES
|
// WITH_COROUTINES
|
||||||
import helpers.*
|
import helpers.*
|
||||||
// TREAT_AS_ONE_FILE
|
// TREAT_AS_ONE_FILE
|
||||||
import COROUTINES_PACKAGE.*
|
import kotlin.coroutines.*
|
||||||
import COROUTINES_PACKAGE.intrinsics.*
|
import kotlin.coroutines.intrinsics.*
|
||||||
suspend fun suspendHere(): String = suspendCoroutineOrReturn { x ->
|
suspend fun suspendHere(): String = suspendCoroutineOrReturn { x ->
|
||||||
x.resume("OK")
|
x.resume("OK")
|
||||||
}
|
}
|
||||||
@@ -42,8 +42,8 @@ fun box(): String {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1 LOCALVARIABLE i I L.* 3
|
// 1 LOCALVARIABLE i I L.* 2
|
||||||
// 1 LOCALVARIABLE s Ljava/lang/String; L.* 3
|
// 1 LOCALVARIABLE s Ljava/lang/String; L.* 2
|
||||||
// 0 PUTFIELD VarValueConflictsWithTableKt\$box\$1.I\$0 : I
|
// 0 PUTFIELD VarValueConflictsWithTableKt\$box\$1.I\$0 : I
|
||||||
/* 2 loads in cycle */
|
/* 2 loads in cycle */
|
||||||
// 2 ILOAD 3
|
// 2 ILOAD 2
|
||||||
|
|||||||
+5
-6
@@ -1,13 +1,11 @@
|
|||||||
|
// LANGUAGE_VERSION: 1.3
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// COMMON_COROUTINES_TEST
|
|
||||||
// WITH_COROUTINES
|
// WITH_COROUTINES
|
||||||
import helpers.*
|
import helpers.*
|
||||||
// TREAT_AS_ONE_FILE
|
// TREAT_AS_ONE_FILE
|
||||||
import COROUTINES_PACKAGE.*
|
import kotlin.coroutines.*
|
||||||
import COROUTINES_PACKAGE.intrinsics.*
|
import kotlin.coroutines.intrinsics.*
|
||||||
suspend fun suspendHere(): String = suspendCoroutineOrReturn { x ->
|
suspend fun suspendHere(): String = ""
|
||||||
x.resume("OK")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun builder(c: suspend () -> Unit) {
|
fun builder(c: suspend () -> Unit) {
|
||||||
c.startCoroutine(EmptyContinuation)
|
c.startCoroutine(EmptyContinuation)
|
||||||
@@ -17,6 +15,7 @@ fun box(): String {
|
|||||||
var result = "fail 1"
|
var result = "fail 1"
|
||||||
|
|
||||||
builder {
|
builder {
|
||||||
|
var shiftSlot: String = ""
|
||||||
// Initialize var with Int value
|
// Initialize var with Int value
|
||||||
try {
|
try {
|
||||||
var i: String = "abc"
|
var i: String = "abc"
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ abstract class AbstractBytecodeTextTest : CodegenTestCase() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val expected = readExpectedOccurrences(wholeFile.path)
|
val expected = readExpectedOccurrences(wholeFile.path)
|
||||||
val actual = generateToText()
|
val actual = generateToText("helpers/")
|
||||||
checkGeneratedTextAgainstExpectedOccurrences(actual, expected)
|
checkGeneratedTextAgainstExpectedOccurrences(actual, expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -480,10 +480,15 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
protected String generateToText() {
|
protected String generateToText() {
|
||||||
|
return generateToText(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
protected String generateToText(@Nullable String ignorePathPrefix) {
|
||||||
if (classFileFactory == null) {
|
if (classFileFactory == null) {
|
||||||
classFileFactory = generateFiles(myEnvironment, myFiles);
|
classFileFactory = generateFiles(myEnvironment, myFiles);
|
||||||
}
|
}
|
||||||
return classFileFactory.createText();
|
return classFileFactory.createText(ignorePathPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user