CPU { public void step() { checkState(!halted, "An halted CPU cannot execute the program"); int nextInstruction = getNextWordFromProgram("Should have a next instruction"); decodeInstruction(nextInstruction); } CPU(int... instructions); int getInstructionAddress(); Collection<Integer> getStack(); boolean isHalted(); void run(); void step(); Frame getCurrentFrame();  }
@Test(expected = InvalidProgramException.class) public void testPushShouldBeFollowedByAWord() { CPU cpu = new CPU(PUSH); cpu.step(); }
@Test(expected = InvalidProgramException.class) public void testPopNeedsAnItemOnTheStack() { CPU cpu = new CPU(POP); cpu.step(); }
@Test(expected = InvalidProgramException.class) public void testDupNeedsAnItemOnTheStack() { CPU cpu = new CPU(DUP); cpu.step(); }