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)
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)
def test_has_no_more_instructions(self): parser = create_parser(INSTRUCTIONS) read_x_instructions(parser, len(INSTRUCTIONS)) self.assertFalse(parser.has_more_instructions())
def test_parse_label_instruction(self): parser = create_parser(INSTRUCTIONS) instruction = read_x_instructions(parser, 4) self.assertEqual((InstructionTypes.LABEL.value, "LOOP"), instruction)
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)
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)