### Question:
Assembler { public ScriptDefinition assemble(InputStream in) throws IOException { rs2asmLexer lexer = new rs2asmLexer(new ANTLRInputStream(in)); LexerErrorListener errorListener = new LexerErrorListener(); lexer.addErrorListener(errorListener); CommonTokenStream tokens = new CommonTokenStream(lexer); rs2asmParser parser = new rs2asmParser(tokens); ProgContext progContext = parser.prog(); if (errorListener.getErrors() > 0) { throw new RuntimeException("syntax error"); } ParseTreeWalker walker = new ParseTreeWalker(); LabelVisitor labelVisitor = new LabelVisitor(); walker.walk(labelVisitor, progContext); ScriptWriter listener = new ScriptWriter(instructions, labelVisitor); walker.walk(listener, progContext); return listener.buildScript(); } Assembler(Instructions instructions); ScriptDefinition assemble(InputStream in);  }### Answer:
@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); 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); }
@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); 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)).replaceAll("\r\n", "\n"); logger.info(original); logger.info("-----------------------"); logger.info(out); Assert.assertEquals(original, out); }