Esempio n. 1
0
    def test_print_patch(self):
        commands = """nop +0
acc +1
jmp +4
acc +3
jmp -3
acc -99
acc +1
jmp -4
acc +6"""
        cpu = CPU(commands)
        cpu.find_patch()  # Find and enable patch to exit without loops
        self.assertEqual("Line 7: jmp -4", cpu.print_patch())
Esempio n. 2
0
    def test_find_patch(self):
        commands = """nop +0
acc +1
jmp +4
acc +3
jmp -3
acc -99
acc +1
jmp -4
acc +6"""
        cpu = CPU(commands)
        cpu.find_patch()  # Find and enable patch to exit without loops
        self.assertEqual(CMD.NOP, cpu.patch_instruction)
        self.assertEqual(7, cpu.patch_index)
        self.assertEqual(8, cpu.acc)