public void copy_value_to_register() { var register = Any.Register(); var initialValue = Any.RegisterValue(); var newValue = Any.RegisterValue(); var computer = new MockComputerBuilder() .WithDefaultRegisterValue(register, initialValue) .Build(); var copyInstruction = new CopyValueToRegisterInstruction(register, newValue); copyInstruction.Execute(computer); Assert.AreEqual(newValue, 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']); }