Add basic tests

This commit is contained in:
Gabriel Tofvesson 2020-04-16 03:01:05 +02:00
parent 217a8b4f6f
commit b99cc1939b
4 changed files with 56 additions and 0 deletions

View File

@ -4,6 +4,7 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />

20
test/MergeInject.java Normal file
View File

@ -0,0 +1,20 @@
import dev.w1zzrd.asm.InjectClass;
import dev.w1zzrd.asm.Inject;
import dev.w1zzrd.asm.Merger;
@InjectClass(value = MergeTest.class)
public class MergeInject implements Runnable {
@Inject
public String test(){
System.out.println(Merger.field("s"));
return "Modified";
}
@Override
@Inject
public void run() {
for (int i = 0; i < 5; ++i)
System.out.println(test());
}
}

21
test/MergeTest.java Normal file
View File

@ -0,0 +1,21 @@
public class MergeTest {
private String s = "Hello";
public MergeTest(){
}
public MergeTest(String s) {
this.s = s;
}
public String test(){
return s;
}
public String test1(){
return s;
}
}

14
test/Test.java Normal file
View File

@ -0,0 +1,14 @@
import dev.w1zzrd.asm.Merger;
import java.io.IOException;
public class Test {
public static void main(String... args) throws IOException {
Merger m = new Merger("MergeTest");
m.inject(Merger.getClassNode("MergeInject"));
m.compile();
Runnable r = (Runnable)new MergeTest("Constructor message");
r.run();
}
}