blob: dc45492ef3ad45fc45b31adf23d66cda8d4186a4 (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
package com.replaymod.gradle.remap.pattern
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 TestLambdaExpression {
@Test
fun `should find simply lambda expression`() {
TestData.remap("""
class Test {
private void test() {
a.pkg.A.supplier(() -> "test");
}
}
""".trimIndent(), """
@remap.Pattern
private void pattern(String str) {
return a.pkg.A.supplier(() -> str);
}
""".trimIndent(), """
@remap.Pattern
private void pattern(String str) {
return matched(str);
}
""".trimIndent()) shouldBe """
class Test {
private void test() {
matched("test");
}
}
""".trimIndent()
}
@Test
fun `should find lambda expression with bound arguments`() {
TestData.remap("""
class Test {
private void test() {
a.pkg.A.function(str -> str + "test");
}
}
""".trimIndent(), """
@remap.Pattern
private void pattern(String str) {
return a.pkg.A.function(s -> s + str);
}
""".trimIndent(), """
@remap.Pattern
private void pattern(String str) {
return matched(str);
}
""".trimIndent()) shouldBe """
class Test {
private void test() {
matched("test");
}
}
""".trimIndent()
}
@Test
@Disabled("Not yet implemented. Requires more complex replacement scheme.")
fun `should preserve bound lambda argument names`() {
TestData.remap("""
class Test {
private void test() {
a.pkg.A.function(str -> str + "test");
}
}
""".trimIndent(), """
@remap.Pattern
private void pattern(String str) {
return a.pkg.A.function(s -> s + str);
}
""".trimIndent(), """
@remap.Pattern
private void pattern(String str) {
return matched(s -> s + str);
}
""".trimIndent()) shouldBe """
class Test {
private void test() {
matched(str -> str + "test");
}
}
""".trimIndent()
}
}
|