Esempio n. 1
0
    def test_decrement_cell(self):
        """
        Test that executing a '-' operation decrements the cell
        at the pointer by the correct amount.
        """

        program = Program(1)
        program.cell = 1
        program.execute_one("-")
        self.assertEqual(program.cell, 0, "Cell should be decremented to 0")
Esempio n. 2
0
    def test_loop(self):
        """
        Test that a simple loop will repeat until the end condition
        is met. The cell at the pointer should have a non-zero value
        before the loop and be zero when after the loop.
        """

        program = Program(1)
        program.cell = 3
        program.execute_one(["-"])
        self.assertEqual(program.pointer, 0, "Pointer should be reduced to 0")