From 5504b2ff877609d3800d5fce4fbc36a3b01911a5 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Fri, 27 May 2022 08:46:47 +0200 Subject: Fix nested pattern matching --- .../gradle/remap/pattern/TestFieldReference.kt | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/test/kotlin/com/replaymod/gradle/remap/pattern/TestFieldReference.kt (limited to 'src/test/kotlin/com/replaymod/gradle/remap/pattern') diff --git a/src/test/kotlin/com/replaymod/gradle/remap/pattern/TestFieldReference.kt b/src/test/kotlin/com/replaymod/gradle/remap/pattern/TestFieldReference.kt new file mode 100644 index 0000000..a3a6efc --- /dev/null +++ b/src/test/kotlin/com/replaymod/gradle/remap/pattern/TestFieldReference.kt @@ -0,0 +1,40 @@ +package com.replaymod.gradle.remap.pattern + +import com.replaymod.gradle.remap.util.TestData +import io.kotest.matchers.shouldBe +import org.junit.jupiter.api.Test + +class TestFieldReference { + @Test + fun `should match field on left side of assignment when replaced by field`() { + TestData.remap("test/Test.java", """ + class Test { + Test field; + private void test() { + field = field; + this.field = this.field; + this.field.field = this.field.field; + } + } + """.trimIndent(), """ + @remap.Pattern + private test.Test pattern(test.Test obj) { + return obj.field; + } + """.trimIndent(), """ + @remap.Pattern + private test.Test pattern(test.Test obj) { + return obj.matched; + } + """.trimIndent()) shouldBe """ + class Test { + Test field; + private void test() { + field = field; + this.matched = this.matched; + this.matched.matched = this.matched.matched; + } + } + """.trimIndent() + } +} \ No newline at end of file -- cgit