aboutsummaryrefslogtreecommitdiff
path: root/src/test/kotlin/com/replaymod/gradle/remap
diff options
context:
space:
mode:
authorJonas Herzig <jonas@spark-squared.com>2021-11-11 22:25:12 +0100
committerJonas Herzig <jonas@spark-squared.com>2021-11-12 15:23:25 +0100
commit8b1a5a77e75d868cd13ad7dc4d109125711898ce (patch)
tree11459b5c2727e13a296db56db2ca58c53f9279cc /src/test/kotlin/com/replaymod/gradle/remap
parent9a048424d3273152b02aafff690b8a420eae17e4 (diff)
downloadRemap-8b1a5a77e75d868cd13ad7dc4d109125711898ce.tar.gz
Remap-8b1a5a77e75d868cd13ad7dc4d109125711898ce.tar.bz2
Remap-8b1a5a77e75d868cd13ad7dc4d109125711898ce.zip
Add tests for Kotlin synthetic properties
Diffstat (limited to 'src/test/kotlin/com/replaymod/gradle/remap')
-rw-r--r--src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt b/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt
new file mode 100644
index 0000000..d0f6fc2
--- /dev/null
+++ b/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt
@@ -0,0 +1,100 @@
+package com.replaymod.gradle.remap.mapper.kotlin
+
+import com.replaymod.gradle.remap.util.TestData
+import io.kotest.matchers.shouldBe
+import org.junit.jupiter.api.Disabled
+import org.junit.jupiter.api.Test
+
+class TestKotlinSyntheticProperties {
+ @Test
+ fun `remaps synthetic getter`() {
+ TestData.remapKt("""
+ import a.pkg.A
+ val v = A().syntheticA
+ val b = A().isSyntheticBooleanA
+ """.trimIndent()) shouldBe """
+ import b.pkg.B
+ val v = B().syntheticB
+ val b = B().isSyntheticBooleanB
+ """.trimIndent()
+ }
+
+ @Test
+ fun `remaps synthetic setter`() {
+ TestData.remapKt("""
+ import a.pkg.A
+ fun test() {
+ A().syntheticA = A()
+ A().isSyntheticBooleanA = true
+ }
+ """.trimIndent()) shouldBe """
+ import b.pkg.B
+ fun test() {
+ B().syntheticB = B()
+ B().isSyntheticBooleanB = true
+ }
+ """.trimIndent()
+ }
+
+ @Test
+ fun `converts synthetic property to getter if no longer synthetic`() {
+ TestData.remapKt("""
+ import a.pkg.A
+ val v = A().nonSyntheticA
+ val b = A().isNonSyntheticBooleanA
+ """.trimIndent()) shouldBe """
+ import b.pkg.B
+ val v = B().getterB()
+ val b = B().getterBooleanB()
+ """.trimIndent()
+ }
+
+ @Test
+ fun `converts getter to synthetic property if now synthetic`() {
+ TestData.remapKt("""
+ import a.pkg.A
+ val v = A().getterA()
+ val b = A().getterBooleanA()
+ """.trimIndent()) shouldBe """
+ import b.pkg.B
+ val v = B().nonSyntheticB
+ val b = B().isNonSyntheticBooleanB
+ """.trimIndent()
+ }
+
+ @Test
+ @Disabled("not yet implemented")
+ fun `converts synthetic property to setter if no longer synthetic`() {
+ TestData.remapKt("""
+ import a.pkg.A
+ fun test() {
+ A().nonSyntheticA = A()
+ A().isNonSyntheticBooleanA = true
+ }
+ """.trimIndent()) shouldBe """
+ import b.pkg.B
+ fun test() {
+ B().setterB(B())
+ B().setterBooleanB(true)
+ }
+ """.trimIndent()
+ }
+
+ @Test
+ @Disabled("not yet implemented")
+ fun `converts setter to synthetic property if now synthetic`() {
+ TestData.remapKt("""
+ import a.pkg.A
+ fun test() {
+ A().setterA(A())
+ A().setterBooleanA(true)
+ }
+ """.trimIndent()) shouldBe """
+ import b.pkg.B
+ fun test() {
+ B().nonSyntheticB = B()
+ B().isNonSyntheticBooleanB = true
+ }
+ """.trimIndent()
+ }
+}