diff options
Diffstat (limited to 'src/test/kotlin/com/replaymod/gradle')
4 files changed, 136 insertions, 0 deletions
diff --git a/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinGenerics.kt b/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinGenerics.kt new file mode 100644 index 0000000..19a3574 --- /dev/null +++ b/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinGenerics.kt @@ -0,0 +1,49 @@ +package com.replaymod.gradle.remap.mapper.kotlin + +import com.replaymod.gradle.remap.util.TestData +import io.kotest.matchers.collections.shouldHaveSize +import io.kotest.matchers.shouldBe +import io.kotest.matchers.string.shouldContain +import org.junit.jupiter.api.Test + +class TestKotlinGenerics { + @Test + fun `remaps generic type argument`() { + TestData.remapKt(""" + val test: List<a.pkg.A> = TODO() + """.trimIndent()) shouldBe """ + val test: List<b.pkg.B> = TODO() + """.trimIndent() + } + + @Test + fun `remaps generic type argument with import`() { + TestData.remapKt(""" + import a.pkg.A + val test: List<A> = TODO() + """.trimIndent()) shouldBe """ + import b.pkg.B + val test: List<B> = TODO() + """.trimIndent() + } + + @Test + fun `remaps generic type`() { + TestData.remapKt(""" + val test: a.pkg.A.GenericA<Int> = TODO() + """.trimIndent()) shouldBe """ + val test: b.pkg.B.GenericB<Int> = TODO() + """.trimIndent() + } + + @Test + fun `remaps generic type with import`() { + TestData.remapKt(""" + import a.pkg.A.GenericA + val test: GenericA<Int> = TODO() + """.trimIndent()) shouldBe """ + import b.pkg.B.GenericB + val test: GenericB<Int> = TODO() + """.trimIndent() + } +}
\ No newline at end of file diff --git a/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinImports.kt b/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinImports.kt new file mode 100644 index 0000000..3193c2f --- /dev/null +++ b/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinImports.kt @@ -0,0 +1,42 @@ +package com.replaymod.gradle.remap.mapper.kotlin + +import com.replaymod.gradle.remap.util.TestData +import io.kotest.matchers.collections.shouldHaveSize +import io.kotest.matchers.shouldBe +import io.kotest.matchers.string.shouldContain +import org.junit.jupiter.api.Test + +class TestKotlinImports { + @Test + fun `remaps simple import`() { + TestData.remapKt(""" + import a.pkg.A + val test: A = TODO() + """.trimIndent()) shouldBe """ + import b.pkg.B + val test: B = TODO() + """.trimIndent() + } + + @Test + fun `remaps outer class of inner class import`() { + TestData.remapKt(""" + import a.pkg.A.Inner + val test: Inner = TODO() + """.trimIndent()) shouldBe """ + import b.pkg.B.Inner + val test: Inner = TODO() + """.trimIndent() + } + + @Test + fun `remaps inner class import`() { + TestData.remapKt(""" + import a.pkg.A.InnerA + val test: InnerA = TODO() + """.trimIndent()) shouldBe """ + import b.pkg.B.InnerB + val test: InnerB = TODO() + """.trimIndent() + } +}
\ No newline at end of file diff --git a/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinTypeAliases.kt b/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinTypeAliases.kt new file mode 100644 index 0000000..0d69341 --- /dev/null +++ b/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinTypeAliases.kt @@ -0,0 +1,42 @@ +package com.replaymod.gradle.remap.mapper.kotlin + +import com.replaymod.gradle.remap.util.TestData +import io.kotest.matchers.collections.shouldHaveSize +import io.kotest.matchers.shouldBe +import io.kotest.matchers.string.shouldContain +import org.junit.jupiter.api.Test + +class TestKotlinTypeAliases { + @Test + fun `remaps simple alias`() { + TestData.remapKt(""" + typealias A = a.pkg.A + val test: A = TODO() + """.trimIndent()) shouldBe """ + typealias A = b.pkg.B + val test: A = TODO() + """.trimIndent() + } + + @Test + fun `remaps outer class of inner class alias`() { + TestData.remapKt(""" + typealias Inner = a.pkg.A.Inner + val test: Inner = TODO() + """.trimIndent()) shouldBe """ + typealias Inner = b.pkg.B.Inner + val test: Inner = TODO() + """.trimIndent() + } + + @Test + fun `remaps inner class alias`() { + TestData.remapKt(""" + typealias InnerA = a.pkg.A.InnerA + val test: InnerA = TODO() + """.trimIndent()) shouldBe """ + typealias InnerA = b.pkg.B.InnerB + val test: InnerA = TODO() + """.trimIndent() + } +}
\ No newline at end of file diff --git a/src/test/kotlin/com/replaymod/gradle/remap/util/TestData.kt b/src/test/kotlin/com/replaymod/gradle/remap/util/TestData.kt index cb0ad44..0f83373 100644 --- a/src/test/kotlin/com/replaymod/gradle/remap/util/TestData.kt +++ b/src/test/kotlin/com/replaymod/gradle/remap/util/TestData.kt @@ -45,4 +45,7 @@ object TestData { fun remap(content: String): String = transformer.remap(mapOf("test.java" to content))["test.java"]!!.first fun remapWithErrors(content: String) = transformer.remap(mapOf("test.java" to content))["test.java"]!! + + fun remapKt(content: String): String = transformer.remap(mapOf("test.kt" to content))["test.kt"]!!.first + fun remapKtWithErrors(content: String) = transformer.remap(mapOf("test.kt" to content))["test.kt"]!! }
\ No newline at end of file |