Exemple #1
0
def _(operand):
    if all(isinstance(item, Register) for item in operand):
        return Registers(operand)
    elif all(isinstance(item, (Integral, Label)) for item in operand):
        return Integers(operand)
    else:
        raise TypeError("{} could not be parsed".format(operand))
def test_registers_inequality_different_types(s):
    u = tuple(s)
    assert Registers(u) != object()
def test_registers_hash_equal(s):
    u = tuple(s)
    v = tuple(s)
    assert hash(Registers(u)) == hash(Registers(v))
def test_registers_equality(s):
    u = tuple(s)
    v = tuple(s)
    assert Registers(u) == Registers(v)
def test_registers_inequality(s, t):
    assume(s != t)
    u = tuple(s)
    v = tuple(t)
    assert Registers(u) != Registers(v)
def test_registers_value(s):
    t = tuple(s)
    assert Registers(t).registers == t
def test_empty_registers_raises_value_error():
    t = tuple()
    with raises(ValueError):
        Registers(t)
def test_registers_repr(s):
    r = repr(Registers(s))
    assert r.startswith('Registers')
    assert all(register.name in r for register in s)
    assert check_balanced(r)
Exemple #9
0
def test_register_seven_address_assembly():
    asm = AsmDsl()
    asm(PSHS, (PC, U, Y, X, DP, B, A, CC))
    assert statements(asm) == (PshS(Registers((PC, U, Y, X, DP, B, A, CC))), )
Exemple #10
0
def test_register_two_address_assembly():
    asm = AsmDsl()
    asm(TFR, (A, B))
    assert statements(asm) == (Tfr(Registers((A, B))), )