Refactoring: merge doTest in AbstractMultiModuleHighlightingTest
This commit is contained in:
+31
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.caches.resolve
|
package org.jetbrains.kotlin.idea.caches.resolve
|
||||||
|
|
||||||
|
import com.intellij.openapi.module.Module
|
||||||
|
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
||||||
|
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||||
import org.jetbrains.kotlin.idea.project.PluginJetFilesProvider
|
import org.jetbrains.kotlin.idea.project.PluginJetFilesProvider
|
||||||
import org.jetbrains.kotlin.idea.stubs.AbstractMultiHighlightingTest
|
import org.jetbrains.kotlin.idea.stubs.AbstractMultiHighlightingTest
|
||||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||||
@@ -25,6 +28,34 @@ abstract class AbstractMultiModuleHighlightingTest : AbstractMultiHighlightingTe
|
|||||||
|
|
||||||
override val testPath = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleHighlighting/"
|
override val testPath = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleHighlighting/"
|
||||||
|
|
||||||
|
protected fun doMultiPlatformTest(
|
||||||
|
vararg platforms: TargetPlatformKind<*>,
|
||||||
|
withStdlibCommon: Boolean = false,
|
||||||
|
configureModule: (Module, TargetPlatformKind<*>) -> Unit = { _, _ -> },
|
||||||
|
useFullJdk: Boolean = false
|
||||||
|
) {
|
||||||
|
val commonModule = module("common", useFullJdk = useFullJdk)
|
||||||
|
commonModule.createFacet(TargetPlatformKind.Common)
|
||||||
|
if (withStdlibCommon) {
|
||||||
|
commonModule.addLibrary(ForTestCompileRuntime.stdlibCommonForTests())
|
||||||
|
}
|
||||||
|
|
||||||
|
for (platform in platforms) {
|
||||||
|
val path = when (platform) {
|
||||||
|
is TargetPlatformKind.Jvm -> "jvm"
|
||||||
|
is TargetPlatformKind.JavaScript -> "js"
|
||||||
|
else -> error("Unsupported platform: $platform")
|
||||||
|
}
|
||||||
|
val platformModule = module(path, useFullJdk = useFullJdk)
|
||||||
|
platformModule.createFacet(platform)
|
||||||
|
platformModule.enableMultiPlatform()
|
||||||
|
platformModule.addDependency(commonModule)
|
||||||
|
configureModule(platformModule, platform)
|
||||||
|
}
|
||||||
|
|
||||||
|
checkHighlightingInAllFiles()
|
||||||
|
}
|
||||||
|
|
||||||
protected fun checkHighlightingInAllFiles() {
|
protected fun checkHighlightingInAllFiles() {
|
||||||
var atLeastOneFile = false
|
var atLeastOneFile = false
|
||||||
PluginJetFilesProvider.allFilesInProject(myProject!!).forEach { file ->
|
PluginJetFilesProvider.allFilesInProject(myProject!!).forEach { file ->
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.caches.resolve
|
package org.jetbrains.kotlin.idea.caches.resolve
|
||||||
|
|
||||||
import com.intellij.openapi.module.Module
|
|
||||||
import com.intellij.openapi.roots.DependencyScope
|
import com.intellij.openapi.roots.DependencyScope
|
||||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
||||||
import org.jetbrains.kotlin.config.JvmTarget
|
import org.jetbrains.kotlin.config.JvmTarget
|
||||||
@@ -66,65 +65,37 @@ class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
|||||||
class MultiPlatform : AbstractMultiModuleHighlightingTest() {
|
class MultiPlatform : AbstractMultiModuleHighlightingTest() {
|
||||||
override val testPath get() = super.testPath + "multiplatform/"
|
override val testPath get() = super.testPath + "multiplatform/"
|
||||||
|
|
||||||
private fun doTest(
|
|
||||||
vararg platforms: TargetPlatformKind<*>,
|
|
||||||
withStdlibCommon: Boolean = false,
|
|
||||||
configureModule: (Module, TargetPlatformKind<*>) -> Unit = { _, _ -> },
|
|
||||||
useFullJdk: Boolean = false
|
|
||||||
) {
|
|
||||||
val commonModule = module("common", useFullJdk = useFullJdk)
|
|
||||||
commonModule.createFacet(TargetPlatformKind.Common)
|
|
||||||
if (withStdlibCommon) {
|
|
||||||
commonModule.addLibrary(ForTestCompileRuntime.stdlibCommonForTests())
|
|
||||||
}
|
|
||||||
|
|
||||||
for (platform in platforms) {
|
|
||||||
val path = when (platform) {
|
|
||||||
is TargetPlatformKind.Jvm -> "jvm"
|
|
||||||
is TargetPlatformKind.JavaScript -> "js"
|
|
||||||
else -> error("Unsupported platform: $platform")
|
|
||||||
}
|
|
||||||
val platformModule = module(path, useFullJdk = useFullJdk)
|
|
||||||
platformModule.createFacet(platform)
|
|
||||||
platformModule.enableMultiPlatform()
|
|
||||||
platformModule.addDependency(commonModule)
|
|
||||||
configureModule(platformModule, platform)
|
|
||||||
}
|
|
||||||
|
|
||||||
checkHighlightingInAllFiles()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testBasic() {
|
fun testBasic() {
|
||||||
doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testHeaderClass() {
|
fun testHeaderClass() {
|
||||||
doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testHeaderWithoutImplForBoth() {
|
fun testHeaderWithoutImplForBoth() {
|
||||||
doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], TargetPlatformKind.JavaScript)
|
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], TargetPlatformKind.JavaScript)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testHeaderPartiallyImplemented() {
|
fun testHeaderPartiallyImplemented() {
|
||||||
doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testHeaderFunctionProperty() {
|
fun testHeaderFunctionProperty() {
|
||||||
doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testSuppressHeaderWithoutImpl() {
|
fun testSuppressHeaderWithoutImpl() {
|
||||||
doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testCatchHeaderExceptionInPlatformModule() {
|
fun testCatchHeaderExceptionInPlatformModule() {
|
||||||
doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], withStdlibCommon = true)
|
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], withStdlibCommon = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testUseCorrectBuiltInsForCommonModule() {
|
fun testUseCorrectBuiltInsForCommonModule() {
|
||||||
doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_8], TargetPlatformKind.JavaScript,
|
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_8], TargetPlatformKind.JavaScript,
|
||||||
withStdlibCommon = true, useFullJdk = true, configureModule = { module, platform ->
|
withStdlibCommon = true, useFullJdk = true, configureModule = { module, platform ->
|
||||||
if (platform == TargetPlatformKind.JavaScript) {
|
if (platform == TargetPlatformKind.JavaScript) {
|
||||||
module.addLibrary(ForTestCompileRuntime.stdlibJsForTests())
|
module.addLibrary(ForTestCompileRuntime.stdlibJsForTests())
|
||||||
module.addLibrary(ForTestCompileRuntime.stdlibCommonForTests())
|
module.addLibrary(ForTestCompileRuntime.stdlibCommonForTests())
|
||||||
|
|||||||
@@ -21,34 +21,15 @@ import org.jetbrains.kotlin.config.TargetPlatformKind
|
|||||||
|
|
||||||
class MultiModuleLineMarkerTest : AbstractMultiModuleLineMarkerTest() {
|
class MultiModuleLineMarkerTest : AbstractMultiModuleLineMarkerTest() {
|
||||||
|
|
||||||
private fun doTest(vararg platforms: TargetPlatformKind<*>) {
|
|
||||||
val commonModule = module("common")
|
|
||||||
commonModule.createFacet(TargetPlatformKind.Common)
|
|
||||||
|
|
||||||
for (platform in platforms) {
|
|
||||||
val path = when (platform) {
|
|
||||||
is TargetPlatformKind.Jvm -> "jvm"
|
|
||||||
is TargetPlatformKind.JavaScript -> "js"
|
|
||||||
else -> error("Unsupported platform: $platform")
|
|
||||||
}
|
|
||||||
val platformModule = module(path)
|
|
||||||
platformModule.createFacet(platform)
|
|
||||||
platformModule.enableMultiPlatform()
|
|
||||||
platformModule.addDependency(commonModule)
|
|
||||||
}
|
|
||||||
|
|
||||||
checkHighlightingInAllFiles()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testFromCommonToJvmHeader() {
|
fun testFromCommonToJvmHeader() {
|
||||||
doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testFromCommonToJvmImpl() {
|
fun testFromCommonToJvmImpl() {
|
||||||
doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testFromClassToAlias() {
|
fun testFromClassToAlias() {
|
||||||
doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.stubs
|
package org.jetbrains.kotlin.idea.stubs
|
||||||
|
|
||||||
import com.intellij.codeInsight.completion.CompletionTestCase
|
|
||||||
import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase
|
|
||||||
import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl
|
import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl
|
||||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo
|
import com.intellij.codeInsight.daemon.impl.HighlightInfo
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
|
|||||||
Reference in New Issue
Block a user