Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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())
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)