Exemple #1
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)
Exemple #2
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)
Exemple #3
0
 def test_has_no_more_instructions(self):
     parser = create_parser(INSTRUCTIONS)
     read_x_instructions(parser, len(INSTRUCTIONS))
     self.assertFalse(parser.has_more_instructions())
Exemple #4
0
 def test_parse_label_instruction(self):
     parser = create_parser(INSTRUCTIONS)
     instruction = read_x_instructions(parser, 4)
     self.assertEqual((InstructionTypes.LABEL.value, "LOOP"), instruction)
Exemple #5
0
 def test_parse_c_instruction_3(self):
     parser = create_parser(INSTRUCTIONS)
     instruction = read_x_instructions(parser, 7)
     self.assertEqual((InstructionTypes.C.value, ("", "0", "JMP")),
                      instruction)
Exemple #6
0
 def test_get_label_instruction_type(self):
     parser = create_parser(INSTRUCTIONS)
     read_x_instructions(parser, 3)
     instruction_type = parser.get_instruction_type()
     self.assertEqual(InstructionTypes.LABEL.value, instruction_type)