public void decrement_register() { var register = Any.Register(); var initialRegisterValue = Any.RegisterValue(); var computer = new MockComputerBuilder(). WithDefaultRegisterValue(register, initialRegisterValue) .Build(); var instruction = new DecrementInstruction(register); instruction.Execute(computer); Assert.AreEqual(initialRegisterValue - 1, computer[register]); }
public void execute_all_with_jump() { var instructions = new IInstruction[6]; instructions[0] = new CopyValueToRegisterInstruction('a', 41); instructions[1] = new IncrementInstruction('a'); instructions[2] = new IncrementInstruction('a'); instructions[3] = new DecrementInstruction('a'); instructions[4] = new JumpInstruction('a', 2); instructions[5] = new DecrementInstruction('a'); var computer = new MockComputerBuilder() .WithInstructions(instructions) .Build(); computer.ExecuteAll(); Assert.AreEqual(42, computer['a']); }
public void EmitDecrement(Type type) { Emit(DecrementInstruction.Create(type)); }