def test_jump_lt_zero(self): line = 'D=A;JLT' instruction = assembler.parse_c_instruction(line) expected_jump_code = '100' self.assertEqual(expected_jump_code, instruction[13:])
def test_no_jump(self): line = 'D=A' instruction = assembler.parse_c_instruction(line) expected_jump_code = '000' self.assertEqual(expected_jump_code, instruction[13:])
def test_unconditional_jump(self): line = 'D=A;JMP' instruction = assembler.parse_c_instruction(line) expected_jump_code = '111' self.assertEqual(expected_jump_code, instruction[13:])
def test_store_md(self): line = 'MD=0;JMP' instruction = assembler.parse_c_instruction(line) expected_dest_code = '011' self.assertEqual(expected_dest_code, instruction[10:13])
def test_store_nowhere(self): line = '0;JMP' instruction = assembler.parse_c_instruction(line) expected_dest_code = '000' self.assertEqual(expected_dest_code, instruction[10:13])
def test_m_minus_d(self): line = 'D=A-D;JNE' instruction = assembler.parse_c_instruction(line) expected_comp_code = '000111' self.assertEqual(expected_comp_code, instruction[4:10])
def test_a_and_d(self): line = 'M=A&D;JLE' instruction = assembler.parse_c_instruction(line) expected_comp_code = '000000' self.assertEqual(expected_comp_code, instruction[4:10])
def test_a_flag_default(self): line = 'D=1' instruction = assembler.parse_c_instruction(line) expected_a_flag = '0' self.assertEqual(expected_a_flag, instruction[3])
def test_a_flag_a(self): line = 'D=D+M' instruction = assembler.parse_c_instruction(line) expected_a_flag = '1' self.assertEqual(expected_a_flag, instruction[3])
def test_op_code(self): line = 'AMD=0;JMP' instruction = assembler.parse_c_instruction(line) expected_op_code = '111' self.assertEqual(expected_op_code, instruction[:3])