Search in sources :

Example 1 with Instructions

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);
}
Also used : ScriptDefinition(net.runelite.cache.definitions.ScriptDefinition) Instructions(net.runelite.cache.script.Instructions) Assembler(net.runelite.cache.script.assembler.Assembler) ScriptLoader(net.runelite.cache.definitions.loaders.ScriptLoader) Test(org.junit.Test)

Example 2 with Instructions

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);
}
Also used : ScriptDefinition(net.runelite.cache.definitions.ScriptDefinition) InputStream(java.io.InputStream) Disassembler(net.runelite.cache.script.disassembler.Disassembler) Instructions(net.runelite.cache.script.Instructions) Test(org.junit.Test)

Aggregations

ScriptDefinition (net.runelite.cache.definitions.ScriptDefinition)2 Instructions (net.runelite.cache.script.Instructions)2 Test (org.junit.Test)2 InputStream (java.io.InputStream)1 ScriptLoader (net.runelite.cache.definitions.loaders.ScriptLoader)1 Assembler (net.runelite.cache.script.assembler.Assembler)1 Disassembler (net.runelite.cache.script.disassembler.Disassembler)1