From a0a70dd60d8be7a14c65ed0a894fa24f083bdaf2 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 18 Dec 2018 16:47:28 +0100 Subject: [PATCH] Remove LANGUAGE_VERSION from compileKotlinAgainstKotlin tests Support test directives not at the beginning of the test file for multi-file tests where separate files need separate language features --- .../coroutines/builder.kt | 5 ++-- .../coroutines/lambda.kt | 28 ------------------- .../coroutines/receiver.kt | 5 ++-- .../coroutines/simple.kt | 5 ++-- .../kotlin/test/KotlinTestUtils.java | 5 ---- .../kotlin/test/KotlinTestUtils.java.173 | 5 ---- .../kotlin/test/KotlinTestUtils.java.as31 | 5 ---- .../kotlin/test/KotlinTestUtils.java.as32 | 5 ---- ...mpileKotlinAgainstKotlinTestGenerated.java | 5 ---- 9 files changed, 9 insertions(+), 59 deletions(-) delete mode 100644 compiler/testData/compileKotlinAgainstKotlin/coroutines/lambda.kt diff --git a/compiler/testData/compileKotlinAgainstKotlin/coroutines/builder.kt b/compiler/testData/compileKotlinAgainstKotlin/coroutines/builder.kt index 2819b76ba00..26ad3aeaeeb 100644 --- a/compiler/testData/compileKotlinAgainstKotlin/coroutines/builder.kt +++ b/compiler/testData/compileKotlinAgainstKotlin/coroutines/builder.kt @@ -1,7 +1,8 @@ // FILE: A.kt -// LANGUAGE_VERSION: 1.2 +// !LANGUAGE: -ReleaseCoroutines // TODO: Unmute when automatic conversion experimental <-> release will be implemented // IGNORE_BACKEND: JS, NATIVE, JVM_IR, JS_IR + import kotlin.coroutines.experimental.* var callback: (() -> Unit)? = null @@ -44,7 +45,7 @@ fun builder2(c: suspend String.() -> String): String { } // FILE: B.kt -// LANGUAGE_VERSION: 1.3 + import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* diff --git a/compiler/testData/compileKotlinAgainstKotlin/coroutines/lambda.kt b/compiler/testData/compileKotlinAgainstKotlin/coroutines/lambda.kt deleted file mode 100644 index 8bd6990413f..00000000000 --- a/compiler/testData/compileKotlinAgainstKotlin/coroutines/lambda.kt +++ /dev/null @@ -1,28 +0,0 @@ -// FILE: A.kt -// LANGUAGE_VERSION: 1.2 -// TODO: Unmute when automatic conversion experimental <-> release will be implemented -// IGNORE_BACKEND: JVM, JS, NATIVE, JVM_IR, JS_IR - -val dummy1: suspend () -> String = { "OK" } -val dummy2: suspend String.() -> String = { this + "K" } -val dummy3: suspend String.(String) -> String = { s -> this + s } - -// FILE: B.kt -// LANGUAGE_VERSION: 1.3 -import kotlin.coroutines.experimental.* - -fun box(): String { -// val continuation = object : Continuation { -// override val context = EmptyCoroutineContext -// override fun resume(value: String) { -// } -// -// override fun resumeWithException(exception: Throwable) { -// throw exception -// } -// } -// if (dummy1(continuation) != "OK") return "FAIL 1" -// if ("O".dummy2(continuation) != "OK") return "FAIL 2" -// if ("O".dummy3("K", continuation) != "OK") return "FAIL 3" - return "OK" -} diff --git a/compiler/testData/compileKotlinAgainstKotlin/coroutines/receiver.kt b/compiler/testData/compileKotlinAgainstKotlin/coroutines/receiver.kt index d76012f5e71..c76be5e5be5 100644 --- a/compiler/testData/compileKotlinAgainstKotlin/coroutines/receiver.kt +++ b/compiler/testData/compileKotlinAgainstKotlin/coroutines/receiver.kt @@ -1,7 +1,8 @@ // FILE: A.kt -// LANGUAGE_VERSION: 1.2 +// !LANGUAGE: -ReleaseCoroutines // TODO: Unmute when automatic conversion experimental <-> release will be implemented // IGNORE_BACKEND: JS, NATIVE, JVM_IR, JS_IR + import kotlin.coroutines.experimental.* var callback: (() -> Unit)? = null @@ -31,7 +32,7 @@ fun (suspend () -> String).builder(): String { } // FILE: B.kt -// LANGUAGE_VERSION: 1.3 + import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* diff --git a/compiler/testData/compileKotlinAgainstKotlin/coroutines/simple.kt b/compiler/testData/compileKotlinAgainstKotlin/coroutines/simple.kt index f78daed0d4f..63c83219549 100644 --- a/compiler/testData/compileKotlinAgainstKotlin/coroutines/simple.kt +++ b/compiler/testData/compileKotlinAgainstKotlin/coroutines/simple.kt @@ -1,7 +1,8 @@ // FILE: A.kt -// LANGUAGE_VERSION: 1.2 +// !LANGUAGE: -ReleaseCoroutines // TODO: Unmute when automatic conversion experimental <-> release will be implemented // IGNORE_BACKEND: JS, NATIVE, JVM_IR, JS_IR + import kotlin.coroutines.experimental.* import kotlin.coroutines.experimental.intrinsics.* @@ -11,7 +12,7 @@ suspend fun dummy(): String = suspendCoroutine { } // FILE: B.kt -// LANGUAGE_VERSION: 1.3 + import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java index 1e2625a5419..fc412d1278d 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -842,16 +842,11 @@ public class KotlinTestUtils { public static Map parseDirectives(String expectedText) { Map directives = new HashMap<>(); Matcher directiveMatcher = DIRECTIVE_PATTERN.matcher(expectedText); - int start = 0; while (directiveMatcher.find()) { - if (directiveMatcher.start() != start) { - Assert.fail("Directives should only occur at the beginning of a file: " + directiveMatcher.group()); - } String name = directiveMatcher.group(1); String value = directiveMatcher.group(3); String oldValue = directives.put(name, value); Assert.assertNull("Directive overwritten: " + name + " old value: " + oldValue + " new value: " + value, oldValue); - start = directiveMatcher.end() + 1; } return directives; } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.173 b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.173 index dac306d7ae6..9830c40f87b 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.173 +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.173 @@ -838,16 +838,11 @@ public class KotlinTestUtils { public static Map parseDirectives(String expectedText) { Map directives = new HashMap<>(); Matcher directiveMatcher = DIRECTIVE_PATTERN.matcher(expectedText); - int start = 0; while (directiveMatcher.find()) { - if (directiveMatcher.start() != start) { - Assert.fail("Directives should only occur at the beginning of a file: " + directiveMatcher.group()); - } String name = directiveMatcher.group(1); String value = directiveMatcher.group(3); String oldValue = directives.put(name, value); Assert.assertNull("Directive overwritten: " + name + " old value: " + oldValue + " new value: " + value, oldValue); - start = directiveMatcher.end() + 1; } return directives; } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as31 b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as31 index 9f1cb5e92ba..43052895878 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as31 +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as31 @@ -838,16 +838,11 @@ public class KotlinTestUtils { public static Map parseDirectives(String expectedText) { Map directives = new HashMap<>(); Matcher directiveMatcher = DIRECTIVE_PATTERN.matcher(expectedText); - int start = 0; while (directiveMatcher.find()) { - if (directiveMatcher.start() != start) { - Assert.fail("Directives should only occur at the beginning of a file: " + directiveMatcher.group()); - } String name = directiveMatcher.group(1); String value = directiveMatcher.group(3); String oldValue = directives.put(name, value); Assert.assertNull("Directive overwritten: " + name + " old value: " + oldValue + " new value: " + value, oldValue); - start = directiveMatcher.end() + 1; } return directives; } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 index b9c84a88579..29934b07cb8 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java.as32 @@ -838,16 +838,11 @@ public class KotlinTestUtils { public static Map parseDirectives(String expectedText) { Map directives = new HashMap<>(); Matcher directiveMatcher = DIRECTIVE_PATTERN.matcher(expectedText); - int start = 0; while (directiveMatcher.find()) { - if (directiveMatcher.start() != start) { - Assert.fail("Directives should only occur at the beginning of a file: " + directiveMatcher.group()); - } String name = directiveMatcher.group(1); String value = directiveMatcher.group(3); String oldValue = directives.put(name, value); Assert.assertNull("Directive overwritten: " + name + " old value: " + oldValue + " new value: " + value, oldValue); - start = directiveMatcher.end() + 1; } return directives; } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java index 983954297af..051f54e3428 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java @@ -320,11 +320,6 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl runTest("compiler/testData/compileKotlinAgainstKotlin/coroutines/builder.kt"); } - @TestMetadata("lambda.kt") - public void testLambda() throws Exception { - runTest("compiler/testData/compileKotlinAgainstKotlin/coroutines/lambda.kt"); - } - @TestMetadata("receiver.kt") public void testReceiver() throws Exception { runTest("compiler/testData/compileKotlinAgainstKotlin/coroutines/receiver.kt");