From 7e3403f6022e01eb2a9d8ad6f8a372d571955731 Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Fri, 17 Apr 2015 16:08:57 +0300 Subject: [PATCH] Add java8 test module and run configuration with initial test --- .idea/modules.xml | 1 + .idea/runConfigurations/Java_8_Tests.xml | 28 +++++++++++ compiler/java8-tests/java8-tests.iml | 25 ++++++++++ .../AbstractBlackBoxCodegenJava8Test.java | 24 +++++++++ ...BlackBoxWithJava8CodegenTestGenerated.java | 50 +++++++++++++++++++ .../boxWithJava/defaultMethodCall/Simple.java | 9 ++++ .../boxWithJava/defaultMethodCall/Simple.kt | 8 +++ .../defaultMethodCallViaTrait/Simple.java | 9 ++++ .../defaultMethodCallViaTrait.kt | 9 ++++ .../kotlin/generators/tests/GenerateTests.kt | 6 +++ 10 files changed, 169 insertions(+) create mode 100644 .idea/runConfigurations/Java_8_Tests.xml create mode 100644 compiler/java8-tests/java8-tests.iml create mode 100644 compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/generated/AbstractBlackBoxCodegenJava8Test.java create mode 100644 compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJava8CodegenTestGenerated.java create mode 100644 compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/Simple.java create mode 100644 compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/Simple.kt create mode 100644 compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaTrait/Simple.java create mode 100644 compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaTrait/defaultMethodCallViaTrait.kt diff --git a/.idea/modules.xml b/.idea/modules.xml index f04d89bf03f..fcc620ddae4 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -37,6 +37,7 @@ + diff --git a/.idea/runConfigurations/Java_8_Tests.xml b/.idea/runConfigurations/Java_8_Tests.xml new file mode 100644 index 00000000000..700f6ca24d6 --- /dev/null +++ b/.idea/runConfigurations/Java_8_Tests.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/compiler/java8-tests/java8-tests.iml b/compiler/java8-tests/java8-tests.iml new file mode 100644 index 00000000000..a9e0d74928b --- /dev/null +++ b/compiler/java8-tests/java8-tests.iml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/generated/AbstractBlackBoxCodegenJava8Test.java b/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/generated/AbstractBlackBoxCodegenJava8Test.java new file mode 100644 index 00000000000..3b24dd1ef07 --- /dev/null +++ b/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/generated/AbstractBlackBoxCodegenJava8Test.java @@ -0,0 +1,24 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen.generated; + +import org.jetbrains.annotations.NotNull; + +public abstract class AbstractBlackBoxCodegenJava8Test extends AbstractBlackBoxCodegenTest { + + +} diff --git a/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJava8CodegenTestGenerated.java b/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJava8CodegenTestGenerated.java new file mode 100644 index 00000000000..dd10429da4f --- /dev/null +++ b/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJava8CodegenTestGenerated.java @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen.generated; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.JetTestUtils; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/codegen/java8/boxWithJava") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInBoxWithJava() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/boxWithJava"), Pattern.compile("^([^\\.]+)$"), true); + } + + @TestMetadata("defaultMethodCall") + public void testDefaultMethodCall() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/"); + doTestWithJava(fileName); + } + + @TestMetadata("defaultMethodCallViaTrait") + public void testDefaultMethodCallViaTrait() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaTrait/"); + doTestWithJava(fileName); + } + +} diff --git a/compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/Simple.java b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/Simple.java new file mode 100644 index 00000000000..9e37ab67659 --- /dev/null +++ b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/Simple.java @@ -0,0 +1,9 @@ +interface Simple { + default String test(String s) { + return s + "K"; + } + + static String testStatic(String s) { + return s + "K"; + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/Simple.kt b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/Simple.kt new file mode 100644 index 00000000000..95f494533b2 --- /dev/null +++ b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/Simple.kt @@ -0,0 +1,8 @@ +class Test : Simple {} + +fun box(): String { + val test = Test().test("O") + if (test != "OK") return "fail $test" + + return Simple.testStatic("O") +} \ No newline at end of file diff --git a/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaTrait/Simple.java b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaTrait/Simple.java new file mode 100644 index 00000000000..9e37ab67659 --- /dev/null +++ b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaTrait/Simple.java @@ -0,0 +1,9 @@ +interface Simple { + default String test(String s) { + return s + "K"; + } + + static String testStatic(String s) { + return s + "K"; + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaTrait/defaultMethodCallViaTrait.kt b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaTrait/defaultMethodCallViaTrait.kt new file mode 100644 index 00000000000..77c2a40cf45 --- /dev/null +++ b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaTrait/defaultMethodCallViaTrait.kt @@ -0,0 +1,9 @@ +trait TestTrait : Simple {} +class Test : TestTrait {} + +fun box(): String { + val test = Test().test("O") + if (test != "OK") return "fail $test" + + return Simple.testStatic("O") +} \ No newline at end of file diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 48384ecc4d1..fc9b14dc088 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -306,6 +306,12 @@ fun main(args: Array) { } } + testGroup("compiler/java8-tests/tests", "compiler/testData") { + testClass(javaClass(), "BlackBoxWithJava8CodegenTestGenerated") { + model("codegen/java8/boxWithJava", testMethod = "doTestWithJava", extension = null, recursive = true, excludeParentDirs = true) + } + } + testGroup("idea/tests", "idea/testData") { testClass(javaClass()) {