forked from FabricMC/unpick
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a goofy test for the DDCM parser
- Loading branch information
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/test/java/daomephsta/unpick/tests/TestDataDrivenConstantMapperParsing.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package daomephsta.unpick.tests; | ||
|
||
import daomephsta.unpick.api.IClassResolver; | ||
import daomephsta.unpick.api.constantmappers.ConstantMappers; | ||
import daomephsta.unpick.api.constantresolvers.ConstantResolvers; | ||
import org.junit.jupiter.api.Test; | ||
import org.objectweb.asm.ClassReader; | ||
import org.objectweb.asm.tree.ClassNode; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URISyntaxException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class TestDataDrivenConstantMapperParsing { | ||
private final Path validSyntax; | ||
|
||
public TestDataDrivenConstantMapperParsing() throws URISyntaxException { | ||
Path dir = getResource("/v2_test_definitions"); | ||
validSyntax = dir.resolve("valid_syntax.unpick"); | ||
} | ||
|
||
private static Path getResource(String name) throws URISyntaxException { | ||
return Paths.get(TestDataDrivenConstantMapperParsing.class.getResource(name).toURI()); | ||
} | ||
|
||
@Test | ||
void testDDCMParseV2() throws IOException { | ||
File file = validSyntax.toFile(); | ||
|
||
try (InputStream stream = Files.newInputStream(file.toPath())) { | ||
// once classes begin being resolved, we know we have successfully parsed the definitions | ||
assertThrows(IClassResolver.ClassResolutionException.class, () -> ConstantMappers.dataDriven(new IClassResolver() { | ||
@Override | ||
public ClassReader resolveClassReader(String binaryName) throws ClassResolutionException { | ||
throw new ClassResolutionException(binaryName); | ||
} | ||
|
||
@Override | ||
public ClassNode resolveClassNode(String binaryName) throws ClassResolutionException { | ||
throw new ClassResolutionException(binaryName); | ||
} | ||
}, ConstantResolvers.bytecodeAnalysis(new MethodMockingClassResolver()), stream)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
v2 | ||
|
||
constant flag org/quiltmc/Gaming GAMING | ||
constant flag org/quiltmc/Gaming NOT_GAMING | ||
|
||
target_method org/quiltmc/Gaming getFlag (I)Z | ||
param 0 flag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters