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