Exemplo n.º 1
0
 def test_push_constant(self):
     args = ['Filename', 'constant', '7']
     expected = ('// push constant 7\n'
                 '@7\n'
                 'D=A\n'
                 '@SP\n'
                 'A=M\n'
                 'M=D\n'
                 '@SP\n'
                 'M=M+1\n')
     actual = trans.parse_push(*args)
     self.assertEqual(expected, actual)
Exemplo n.º 2
0
 def test_push_static(self):
     args = ['Filename', 'static', '7']
     expected = ('// push static 7\n'
                 '@Filename.7\n'
                 'D=M\n'
                 '@SP\n'
                 'A=M\n'
                 'M=D\n'
                 '@SP\n'
                 'M=M+1\n')
     actual = trans.parse_push(*args)
     self.assertEqual(expected, actual)
Exemplo n.º 3
0
 def test_push_pointer_1(self):
     args = ['Filename', 'pointer', '1']
     expected = ('// push pointer 1\n'
                 '@THAT\n'
                 'D=M\n'
                 '@SP\n'
                 'A=M\n'
                 'M=D\n'
                 '@SP\n'
                 'M=M+1\n')
     actual = trans.parse_push(*args)
     self.assertEqual(expected, actual)
Exemplo n.º 4
0
 def test_push_temp(self):
     args = ['Filename', 'temp', '3']
     expected = ('// push temp 3\n'
                 '@3\n'
                 'D=A\n'
                 '@5\n'
                 'A=D+A\n'
                 'D=M\n'
                 '@SP\n'
                 'A=M\n'
                 'M=D\n'
                 '@SP\n'
                 'M=M+1\n')
     actual = trans.parse_push(*args)
     self.assertEqual(expected, actual)
Exemplo n.º 5
0
 def test_push_that(self):
     args = ['Filename', 'that', '7']
     expected = ('// push that 7\n'
                 '@7\n'
                 'D=A\n'
                 '@THAT\n'
                 'A=D+M\n'
                 'D=M\n'
                 '@SP\n'
                 'A=M\n'
                 'M=D\n'
                 '@SP\n'
                 'M=M+1\n')
     actual = trans.parse_push(*args)
     self.assertEqual(expected, actual)
Exemplo n.º 6
0
 def test_push_local(self):
     args = ['Filename', 'local', '7']
     expected = ('// push local 7\n'
                 '@7\n'
                 'D=A\n'
                 '@LCL\n'
                 'A=D+M\n'
                 'D=M\n'
                 '@SP\n'
                 'A=M\n'
                 'M=D\n'
                 '@SP\n'
                 'M=M+1\n')
     actual = trans.parse_push(*args)
     self.assertEqual(expected, actual)