Exemplo n.º 1
0
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))
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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()
Exemplo n.º 5
0
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)))
Exemplo n.º 6
0
def test_label_inequality(name_a, name_b):
    assume(name_a != name_b)
    assert Label(name_a) != Label(name_b)
Exemplo n.º 7
0
def test_label_equality_differing_type(name):
    assume(is_valid_variable_name(name))
    assert Label(name) != object()
Exemplo n.º 8
0
def test_label_hash_equality(name):
    assume(is_valid_variable_name(name))
    assert hash(Label(name)) == hash(Label(name))
Exemplo n.º 9
0
def test_refer_to_label():
    asm = AsmDsl()
    asm.loop(ADDA, 0x30)
    assert asm.loop == Label('loop')
Exemplo n.º 10
0
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)
Exemplo n.º 11
0
def test_illegal_label_name_raises_value_error(name):
    assume(not is_valid_variable_name(name))
    with raises(ValueError):
        Label(name)
Exemplo n.º 12
0
def test_label_value(name):
    assume(is_valid_variable_name(name))
    assert Label(name).name == name
Exemplo n.º 13
0
def test_set_with_label_returns_extended_direct_addressing_mode():
    address = Label('loop')
    operand = {address}
    r = parse_operand(operand)
    assert r.address == address
Exemplo n.º 14
0
def test_refer_to_second_of_doublelabel():
    asm = AsmDsl()
    asm.loop1.loop2(ADDA, 0x30)
    assert asm.loop2 == Label('loop2')
Exemplo n.º 15
0
def test_refer_to_first_of_doublelabel():
    asm = AsmDsl()
    asm.loop1.loop2(ADDA, 0x30)
    assert asm.loop1 == Label('loop1')
Exemplo n.º 16
0
def test_label_equality(name):
    assume(is_valid_variable_name(name))
    assert Label(name) == Label(name)
Exemplo n.º 17
0
def test_list_causes_indirection_for_label():
    address = Label('loop')
    operand = [{address}]
    r = parse_operand(operand)
    assert isinstance(r, ExtendedIndirect)