Beispiel #1
0
def test_auto_incremented_register_inequality(m, n, delta, gamma):
    assume((m != n) or (delta != gamma))
    Register._names_and_widths.clear()
    a = Register(m, len(m))
    b = Register(n, len(n))
    assert AutoIncrementedRegister(a, delta) != AutoIncrementedRegister(
        b, gamma)
Beispiel #2
0
def test_auto_incremented_register_repr(name, delta):
    a = Register(name, len(name))
    r = repr(AutoIncrementedRegister(a, delta))
    assert r.startswith('AutoIncrementedRegister')
    assert name in r
    assert str(delta) in r
    assert check_balanced(r)
Beispiel #3
0
def test_auto_incremented_register_increments_out_of_range_raise_value_error(
        m, delta):
    assume(delta not in {-2, -1, +1, +2})
    Register._names_and_widths.clear()
    r = Register(m, len(m))
    with raises(ValueError):
        AutoIncrementedRegister(r, delta)
Beispiel #4
0
def test_indexed_autoincrement_with_non_zero_offset_raises_value_error(
        index_register, delta, offset):
    assume(offset != 0)
    print(offset)
    with raises(ValueError):
        Indexed(AutoIncrementedRegister(index_register, delta), offset)
Beispiel #5
0
def test_register_pre_decrement(m, delta):
    Register._names_and_widths.clear()
    r = Register(m, len(m))
    assert delta-r == AutoIncrementedRegister(r, -delta)
Beispiel #6
0
def test_register_post_increment(m, delta):
    Register._names_and_widths.clear()
    r = Register(m, len(m))
    assert r+delta == AutoIncrementedRegister(r, delta)
Beispiel #7
0
def test_auto_incremented_register_hash_equality(m, delta):
    Register._names_and_widths.clear()
    a = Register(m, len(m))
    b = Register(m, len(m))
    assert hash(AutoIncrementedRegister(a, delta)) == hash(AutoIncrementedRegister(b, delta))
Beispiel #8
0
def test_auto_incremented_register_inequality_different_types(m, delta):
    Register._names_and_widths.clear()
    a = Register(m, len(m))
    assert AutoIncrementedRegister(a, delta) != object()