From b00673f859058ff180dc16c22e12ac5698ffbab2 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Fri, 12 Nov 2021 19:00:04 +0100 Subject: Implement synthetic property to/from setter conversion --- .../mapper/kotlin/TestKotlinSyntheticProperties.kt | 44 ++++++++++++++++++---- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'src/test/kotlin') 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 index 65459f2..7a4ab4e 100644 --- a/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt +++ b/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt @@ -2,7 +2,6 @@ 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 { @@ -63,37 +62,43 @@ class TestKotlinSyntheticProperties { } @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 + A().isNonSyntheticBooleanA = + // Comment + true // More comment } """.trimIndent()) shouldBe """ import b.pkg.B fun test() { B().setterB(B()) - B().setterBooleanB(true) + B().setterBooleanB( + // Comment + true) // More comment } """.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) + A().setterBooleanA( + // Comment + true) // More comment } """.trimIndent()) shouldBe """ import b.pkg.B fun test() { B().nonSyntheticB = B() - B().isNonSyntheticBooleanB = true + B().isNonSyntheticBooleanB = + // Comment + true // More comment } """.trimIndent() } @@ -170,4 +175,29 @@ class TestKotlinSyntheticProperties { fun test() { Kt().syntheticB = Kt() } """.trimIndent() } + + @Test + fun `does not replace super calls with synthetic properties`() { + TestData.remapKt(""" + import a.pkg.A + class C : A() { + init { + super.getSyntheticA() + super.isSyntheticBooleanA() + super.setSyntheticA(A()) + super.setSyntheticBooleanA(true) + } + } + """.trimIndent()) shouldBe """ + import b.pkg.B + class C : B() { + init { + super.getSyntheticB() + super.isSyntheticBooleanB() + super.setSyntheticB(B()) + super.setSyntheticBooleanB(true) + } + } + """.trimIndent() + } } -- cgit