def test_statement_equality(cls, operand_a, comment_a, label_name_a, operand_b, comment_b, label_name_b): assume(is_valid_variable_name(label_name_a)) assume(is_valid_variable_name(label_name_b)) assume((operand_a != operand_b) or (comment_a != comment_b) or (label_name_a != label_name_b)) assert cls(operand_a, comment_a, Label(label_name_a)) != cls( operand_b, comment_b, Label(label_name_b))
def test_instantiating_concrete_statement(cls, operand, comment, label_name): assume(is_valid_variable_name(label_name)) label = Label(label_name) s = cls(operand, comment, label) assert s.operand == operand assert s.comment == comment assert s.label == label
def test_label_repr(cls, operand, comment, label_name): assume(is_valid_variable_name(label_name)) label = Label(label_name) r = repr(cls(operand, comment, label)) assert r.startswith(cls.__name__) assert repr(operand) in r assert repr(label) in r assert check_balanced(r)
def test_statement_inequality_different_type(cls, operand, comment, label_name): assume(is_valid_variable_name(label_name)) assert cls(operand, comment, Label(label_name)) != object()
def test_statement_hash_equality(cls, operand, comment, label_name): assume(is_valid_variable_name(label_name)) assert hash(cls(operand, comment, Label(label_name))) == hash( cls(operand, comment, Label(label_name)))
def test_label_inequality(name_a, name_b): assume(name_a != name_b) assert Label(name_a) != Label(name_b)
def test_label_equality_differing_type(name): assume(is_valid_variable_name(name)) assert Label(name) != object()
def test_label_hash_equality(name): assume(is_valid_variable_name(name)) assert hash(Label(name)) == hash(Label(name))
def test_refer_to_label(): asm = AsmDsl() asm.loop(ADDA, 0x30) assert asm.loop == Label('loop')
def test_label_repr(name): assume(is_valid_variable_name(name)) r = repr(Label(name)) assert r.startswith('Label') assert name in r assert check_balanced(r)
def test_illegal_label_name_raises_value_error(name): assume(not is_valid_variable_name(name)) with raises(ValueError): Label(name)
def test_label_value(name): assume(is_valid_variable_name(name)) assert Label(name).name == name
def test_set_with_label_returns_extended_direct_addressing_mode(): address = Label('loop') operand = {address} r = parse_operand(operand) assert r.address == address
def test_refer_to_second_of_doublelabel(): asm = AsmDsl() asm.loop1.loop2(ADDA, 0x30) assert asm.loop2 == Label('loop2')
def test_refer_to_first_of_doublelabel(): asm = AsmDsl() asm.loop1.loop2(ADDA, 0x30) assert asm.loop1 == Label('loop1')
def test_label_equality(name): assume(is_valid_variable_name(name)) assert Label(name) == Label(name)
def test_list_causes_indirection_for_label(): address = Label('loop') operand = [{address}] r = parse_operand(operand) assert isinstance(r, ExtendedIndirect)