Check platform<->impl declaration compatibility
For each platform declaration, there must be at least one impl declaration in the module with the compatible signature; similarly, for each impl declaration, there must be at least one platform declaration with the compatible signature. Note that currently the presence of the 'impl' modifier is not checked yet. Also, the sad fact is that if you have platform and impl declarations which are not compatible, you get two errors: on the platform delcaration and on the impl declaration. This needs to be addressed as well
This commit is contained in:
+24
-24
@@ -24,9 +24,9 @@ import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
|
||||
import java.io.File
|
||||
|
||||
class MultiPlatformIntegrationTest : KtUsefulTestCase() {
|
||||
abstract class AbstractMultiPlatformIntegrationTest : KtUsefulTestCase() {
|
||||
fun doTest(directoryPath: String) {
|
||||
val root = File(KotlinTestUtils.getTestDataPathBase() + directoryPath)
|
||||
val root = File(directoryPath).apply { assert(exists()) }
|
||||
val commonSrc = File(root, "common.kt")
|
||||
val jsSrc = File(root, "js.kt")
|
||||
val jvmSrc = File(root, "jvm.kt")
|
||||
@@ -46,31 +46,31 @@ class MultiPlatformIntegrationTest : KtUsefulTestCase() {
|
||||
appendln("Output:")
|
||||
appendln(commonOutput)
|
||||
|
||||
val (jvmOutput, jvmExitCode) = AbstractCliTest.executeCompilerGrabOutput(K2JVMCompiler(), listOf(
|
||||
jvmSrc.absolutePath, commonSrc.absolutePath,
|
||||
"-d", jvmDest.absolutePath,
|
||||
"-Xmulti-platform"
|
||||
))
|
||||
appendln("-- JVM --")
|
||||
appendln("Exit code: $jvmExitCode")
|
||||
appendln("Output:")
|
||||
appendln(jvmOutput)
|
||||
if (jvmSrc.exists()) {
|
||||
val (jvmOutput, jvmExitCode) = AbstractCliTest.executeCompilerGrabOutput(K2JVMCompiler(), listOf(
|
||||
jvmSrc.absolutePath, commonSrc.absolutePath,
|
||||
"-d", jvmDest.absolutePath,
|
||||
"-Xmulti-platform"
|
||||
))
|
||||
appendln("-- JVM --")
|
||||
appendln("Exit code: $jvmExitCode")
|
||||
appendln("Output:")
|
||||
appendln(jvmOutput)
|
||||
}
|
||||
|
||||
val (jsOutput, jsExitCode) = AbstractCliTest.executeCompilerGrabOutput(K2JSCompiler(), listOf(
|
||||
jsSrc.absolutePath, commonSrc.absolutePath,
|
||||
"-output", jsDest.absolutePath,
|
||||
"-Xmulti-platform"
|
||||
))
|
||||
appendln("-- JS --")
|
||||
appendln("Exit code: $jsExitCode")
|
||||
appendln("Output:")
|
||||
append(jsOutput)
|
||||
if (jsSrc.exists()) {
|
||||
val (jsOutput, jsExitCode) = AbstractCliTest.executeCompilerGrabOutput(K2JSCompiler(), listOf(
|
||||
jsSrc.absolutePath, commonSrc.absolutePath,
|
||||
"-output", jsDest.absolutePath,
|
||||
"-Xmulti-platform"
|
||||
))
|
||||
appendln("-- JS --")
|
||||
appendln("Exit code: $jsExitCode")
|
||||
appendln("Output:")
|
||||
append(jsOutput)
|
||||
}
|
||||
}
|
||||
|
||||
KotlinTestUtils.assertEqualsToFile(File(root, "output.txt"), result)
|
||||
}
|
||||
|
||||
fun testSimple() {
|
||||
doTest("/multiplatform/simple/")
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright 2010-2016 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.multiplatform;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
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/multiplatform")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class MultiPlatformIntegrationTestGenerated extends AbstractMultiPlatformIntegrationTest {
|
||||
public void testAllFilesPresentInMultiplatform() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/multiplatform"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("genericDeclarations")
|
||||
public void testGenericDeclarations() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/genericDeclarations/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("implementClassWithTypeAlias")
|
||||
public void testImplementClassWithTypeAlias() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/implementClassWithTypeAlias/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("incompatibleCallables")
|
||||
public void testIncompatibleCallables() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/incompatibleCallables/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("incompatibleClasses")
|
||||
public void testIncompatibleClasses() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/incompatibleClasses/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("incompatibleFunctions")
|
||||
public void testIncompatibleFunctions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/incompatibleFunctions/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("incompatibleProperties")
|
||||
public void testIncompatibleProperties() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/incompatibleProperties/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simple")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/simple/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/multiplatform/classScopes")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ClassScopes extends AbstractMultiPlatformIntegrationTest {
|
||||
public void testAllFilesPresentInClassScopes() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/multiplatform/classScopes"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("constructorIncorrectSignature")
|
||||
public void testConstructorIncorrectSignature() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/classScopes/constructorIncorrectSignature/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("functionIncorrectSignature")
|
||||
public void testFunctionIncorrectSignature() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/classScopes/functionIncorrectSignature/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("missingConstructor")
|
||||
public void testMissingConstructor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/classScopes/missingConstructor/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("missingFunction")
|
||||
public void testMissingFunction() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/classScopes/missingFunction/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simple")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/classScopes/simple/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user