use of net.runelite.cache.script.Instructions in project runelite by runelite.
the class ScriptSaverTest method testSave.
@Test
public void testSave() throws IOException {
Instructions instructions = new Instructions();
instructions.init();
ScriptDefinition script = new Assembler(instructions).assemble(getClass().getResourceAsStream(SCRIPT_RESOURCE));
byte[] saved = new ScriptSaver().save(script);
ScriptDefinition loadedScripot = new ScriptLoader().load(42, saved);
assertEquals(script, loadedScripot);
}
use of net.runelite.cache.script.Instructions in project runelite by runelite.
the class AssemblerTest method testAssemble.
@Test
public void testAssemble() throws Exception {
InputStream in = AssemblerTest.class.getResourceAsStream(script);
Assert.assertNotNull(in);
Instructions instructions = new Instructions();
instructions.init();
Assembler assembler = new Assembler(instructions);
ScriptDefinition script = assembler.assemble(in);
// compare with disassembler
Disassembler disassembler = new Disassembler();
String out = disassembler.disassemble(script);
in = AssemblerTest.class.getResourceAsStream(this.script);
Assert.assertNotNull(in);
String original = new String(IOUtils.toByteArray(in));
logger.info(original);
logger.info("-----------------------");
logger.info(out);
Assert.assertEquals(original, out);
}
Aggregations