aboutsummaryrefslogtreecommitdiff
path: root/src/test/kotlin/com/replaymod/gradle/remap/mapper/TestMixinAnnotation.kt
blob: 595b65f0f155aa2c29b60c7166e3fd6f5fb1526a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.replaymod.gradle.remap.mapper

import com.replaymod.gradle.remap.util.TestData
import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test

class TestMixinAnnotation {
    @Test
    fun `remaps with class target`() {
        TestData.remap("""
            @org.spongepowered.asm.mixin.Mixin(a.pkg.A.class)
            class MixinA { @Shadow private int aField; }
        """.trimIndent()) shouldBe """
            @org.spongepowered.asm.mixin.Mixin(b.pkg.B.class)
            class MixinA { @Shadow private int bField; }
        """.trimIndent()
    }

    @Test
    fun `remaps with string target`() {
        TestData.remap("""
            @org.spongepowered.asm.mixin.Mixin(targets = "a.pkg.A")
            class MixinA { @Shadow private int aField; }
        """.trimIndent()) shouldBe """
            @org.spongepowered.asm.mixin.Mixin(targets = "b.pkg.B")
            class MixinA { @Shadow private int bField; }
        """.trimIndent()
    }

    @Test
    fun `remaps with inner class string target separated by dot`() {
        // FIXME should probably keep the dot?
        TestData.remap("""
            @org.spongepowered.asm.mixin.Mixin(targets = "a.pkg.A.Inner")
            class MixinA { @Shadow private int aField; }
        """.trimIndent()) shouldBe """
            @org.spongepowered.asm.mixin.Mixin(targets = "b.pkg.B${'$'}Inner")
            class MixinA { @Shadow private int bField; }
        """.trimIndent()
    }

    @Test
    fun `remaps with inner class string target separated by dollar`() {
        TestData.remap("""
            @org.spongepowered.asm.mixin.Mixin(targets = "a.pkg.A${'$'}Inner")
            class MixinA { @Shadow private int aField; }
        """.trimIndent()) shouldBe """
            @org.spongepowered.asm.mixin.Mixin(targets = "b.pkg.B${'$'}Inner")
            class MixinA { @Shadow private int bField; }
        """.trimIndent()
    }

    @Test
    fun `remaps with anonymous inner class target`() {
        TestData.remap("""
            @org.spongepowered.asm.mixin.Mixin(targets = "a.pkg.A${'$'}1")
            class MixinA {}
        """.trimIndent()) shouldBe """
            @org.spongepowered.asm.mixin.Mixin(targets = "b.pkg.B${'$'}1")
            class MixinA {}
        """.trimIndent()
    }
}