### Question:
Block { public Instruction previous(Instruction instruction) { var index = instructions.indexOf(instruction); if (index > 0) { return instructions.get(index - 1); } return null; }  void add(Instruction instruction); void remove(Instruction instruction); Instruction last(); Instruction previous(Instruction instruction);  }### Answer:
@Test void testPrevious() { var block = new Block(new Label(0, "block")); var first = dummyInstruction(); var middle = dummyInstruction(); var last = dummyInstruction(); block.add(first); block.add(middle); block.add(last); assertEquals(first, block.previous(middle)); assertEquals(middle, block.previous(last)); assertNull(block.previous(first)); }