示例#1
0
    def test_a_variable(self):
        parser, translator = create_parser_and_translator([])
        instruction = parser.parse("@sum")
        inst = translator.translate(instruction)
        self.assertEqual("0000000000010000", inst)

        instruction = parser.parse("@i")
        inst = translator.translate(instruction)
        self.assertEqual("0000000000010001", inst)

        instruction = parser.parse("@sum")
        inst = translator.translate(instruction)
        self.assertEqual("0000000000010000", inst)
示例#2
0
 def test_c_translation_4(self):
     parser, translator = create_parser_and_translator([])
     instruction = parser.parse("AM=D|M;JLE")
     c_inst = translator.translate(instruction)
     self.assertEqual("1111010101101110", c_inst)
示例#3
0
 def test_c_translation_1(self):
     parser, translator = create_parser_and_translator(INSTRUCTIONS)
     instruction = read_x_instructions(parser, 5)
     c_inst = translator.translate(instruction)
     self.assertEqual("1110110010011111", c_inst)
示例#4
0
 def test_c_translation_2(self):
     parser, translator = create_parser_and_translator([])
     instruction = parser.parse("D")
     c_inst = translator.translate(instruction)
     self.assertEqual("1110001100000000", c_inst)
示例#5
0
 def test_a_translation(self):
     parser, translator = create_parser_and_translator(INSTRUCTIONS)
     instruction = read_x_instructions(parser, 1)
     a_inst = translator.translate(instruction)
     self.assertEqual("0000000000000001", a_inst)