From 933be1e0351c68eafb6adb95179a8952a5bc94a1 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 1 Mar 2016 19:24:31 +0300 Subject: [PATCH] Drop single-file mode of black box codegen tests Add regression test for #KT-5190 --- ...BlackBoxWithJava8CodegenTestGenerated.java | 6 ++++ .../testData/codegen/java8/box/useStream.kt | 13 ++++++++ .../codegen/AbstractBlackBoxCodegenTest.java | 30 +++++++------------ 3 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 compiler/testData/codegen/java8/box/useStream.kt diff --git a/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java b/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java index cd40458c2f7..a8c8c2af314 100644 --- a/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java +++ b/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java @@ -89,6 +89,12 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg doTest(fileName); } + @TestMetadata("useStream.kt") + public void testUseStream() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/useStream.kt"); + doTest(fileName); + } + @TestMetadata("compiler/testData/codegen/java8/box/reflection") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/testData/codegen/java8/box/useStream.kt b/compiler/testData/codegen/java8/box/useStream.kt new file mode 100644 index 00000000000..21d7b3b8c35 --- /dev/null +++ b/compiler/testData/codegen/java8/box/useStream.kt @@ -0,0 +1,13 @@ +// KT-5190 Java 8 Stream.collect couldn't be called +// FULL_JDK + +import java.util.stream.Collectors +import java.util.stream.Stream + +fun box(): String { + val mutableListOf = mutableListOf("OK", "B", "C") + + return test((mutableListOf as java.util.Collection).stream()) as String +} + +fun test(a: Stream) = a.collect(Collectors.toList()).first() diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java index 0f13e3235ef..e9c152ffdca 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractBlackBoxCodegenTest.java @@ -55,13 +55,17 @@ import static org.jetbrains.kotlin.test.KotlinTestUtils.getAnnotationsJar; public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { @Override protected void doMultiFileTest(@NotNull File wholeFile, @NotNull List files, @Nullable File javaFilesDir) throws Exception { - if (files.size() == 1) { - createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY); - blackBoxFileByFullPath(wholeFile.getPath()); - } - else { - doTestMultiFile(files, javaFilesDir); + TestJdkKind jdkKind = TestJdkKind.MOCK_JDK; + List javacOptions = new ArrayList(0); + for (TestFile file : files) { + if (isFullJdkDirectiveDefined(file.content)) { + jdkKind = TestJdkKind.FULL_JDK; + break; + } + javacOptions.addAll(InTextDirectivesUtils.findListWithPrefixes(file.content, "// JAVAC_OPTIONS:")); } + + compileAndRun(files, javaFilesDir, jdkKind, javacOptions); } protected void doTestWithStdlib(@NotNull String filename) { @@ -76,20 +80,6 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { blackBoxFileByFullPath(filename); } - private void doTestMultiFile(@NotNull List files, @Nullable File javaSourceDir) { - TestJdkKind jdkKind = TestJdkKind.MOCK_JDK; - List javacOptions = new ArrayList(0); - for (TestFile file : files) { - if (isFullJdkDirectiveDefined(file.content)) { - jdkKind = TestJdkKind.FULL_JDK; - break; - } - javacOptions.addAll(InTextDirectivesUtils.findListWithPrefixes(file.content, "// JAVAC_OPTIONS:")); - } - - compileAndRun(files, javaSourceDir, jdkKind, javacOptions); - } - protected void compileAndRun( @NotNull List files, @Nullable File javaSourceDir,