Пример #1
0
 def testExecuteInstruction_nop(self):
     expectedAcc = -10
     expectedNext = 1
     acc = -10
     nextInst = 0
     acc, nextInst = executeInstruction('nop', '+', 0, nextInst, acc)
     self.assertEqual(expectedAcc, acc)
     self.assertEqual(expectedNext, nextInst)
Пример #2
0
 def testExecuteInstruction_decreaseNext(self):
     expectedAcc = -10
     expectedNext = 1
     acc = -10
     nextInst = 4
     acc, nextInst = executeInstruction('jmp', '-', 3, nextInst, acc)
     self.assertEqual(expectedAcc, acc)
     self.assertEqual(expectedNext, nextInst)
Пример #3
0
 def testExecuteInstruction_decreaseAcc(self):
     expectedAcc = -10
     expectedNext = 6
     acc = 89
     nextInst = 5
     acc, nextInst = executeInstruction('acc', '-', 99, nextInst, acc)
     self.assertEqual(expectedAcc, acc)
     self.assertEqual(expectedNext, nextInst)
Пример #4
0
 def testExecuteInstruction_increaseNext(self):
     expectedAcc = -10
     expectedNext = 6
     acc = -10
     nextInst = 2
     acc, nextInst = executeInstruction('jmp', '+', 4, nextInst, acc)
     self.assertEqual(expectedAcc, acc)
     self.assertEqual(expectedNext, nextInst)
Пример #5
0
 def testExecuteInstruction_increaseAcc(self):
     expectedAcc = 5
     expectedNext = 4
     acc = 2
     nextInst = 3
     acc, nextInst = executeInstruction('acc', '+', 3, nextInst, acc)
     self.assertEqual(expectedAcc, acc)
     self.assertEqual(expectedNext, nextInst)