Refactor multiplatform test cases in MultiModuleHighlightingTest

Groupt multiplatform test cases in a nested class, get rid of duplicated
code, rename "header" -> "common" where it relates to the common module
This commit is contained in:
Alexander Udalov
2017-04-13 16:29:09 +03:00
parent c41818b6a7
commit 722687acd6
14 changed files with 36 additions and 66 deletions
@@ -61,80 +61,50 @@ class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
checkHighlightingInAllFiles() checkHighlightingInAllFiles()
} }
fun testPlatformBasic() { class MultiPlatform : AbstractMultiModuleHighlightingTest() {
val header = module("header") override val testPath get() = super.testPath + "multiplatform/"
header.createFacet(TargetPlatformKind.Common)
val jvm = module("jvm") private fun doTest(vararg platforms: TargetPlatformKind<*>) {
jvm.createFacet(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) val commonModule = module("common")
jvm.enableMultiPlatform() commonModule.createFacet(TargetPlatformKind.Common)
jvm.addDependency(header)
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() checkHighlightingInAllFiles()
} }
fun testPlatformClass() { fun testBasic() {
val header = module("header") doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
header.createFacet(TargetPlatformKind.Common)
val jvm = module("jvm")
jvm.createFacet(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
jvm.enableMultiPlatform()
jvm.addDependency(header)
checkHighlightingInAllFiles()
} }
fun testPlatformNotImplementedForBoth() { fun testHeaderClass() {
val header = module("header") doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
header.createFacet(TargetPlatformKind.Common)
val jvm = module("jvm")
jvm.createFacet(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
jvm.enableMultiPlatform()
jvm.addDependency(header)
val js = module("js")
js.createFacet(TargetPlatformKind.JavaScript)
js.enableMultiPlatform()
js.addDependency(header)
checkHighlightingInAllFiles()
} }
fun testPlatformPartiallyImplemented() { fun testHeaderWithoutImplForBoth() {
val header = module("header") doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], TargetPlatformKind.JavaScript)
header.createFacet(TargetPlatformKind.Common)
val jvm = module("jvm")
jvm.createFacet(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
jvm.enableMultiPlatform()
jvm.addDependency(header)
checkHighlightingInAllFiles()
} }
fun testPlatformFunctionProperty() { fun testHeaderPartiallyImplemented() {
val header = module("header") doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
header.createFacet(TargetPlatformKind.Common)
val jvm = module("jvm")
jvm.createFacet(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
jvm.enableMultiPlatform()
jvm.addDependency(header)
checkHighlightingInAllFiles()
} }
fun testPlatformSuppress() { fun testHeaderFunctionProperty() {
val header = module("header") doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
header.createFacet(TargetPlatformKind.Common) }
val jvm = module("jvm") fun testSuppressHeaderWithoutImpl() {
jvm.createFacet(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) doTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
jvm.enableMultiPlatform() }
jvm.addDependency(header)
checkHighlightingInAllFiles()
} }
} }