Exemple #1
0
def test_setting_single_bit_to_1():

    bitmask = BitMask("XXXX1")

    my_int = 2
    assert 3 == bitmask.apply(my_int)

    bitmask = BitMask("1XXXX")
    my_int = 2
    assert 18 == bitmask.apply(my_int)
 def __init__(self):
     super().__init__()
     self.mask = BitMask("X" * 36)
Exemple #3
0
def test_memory_applies_mask():
    mem = Memory()
    mem.mask = BitMask("XX01")

    mem[3] = 6  # 6 = 110. With mask becomes 101 = 5
    assert 5 == mem[3]
Exemple #4
0
def test_repr():
    bitmask = BitMask("X11X001")
    assert repr(bitmask) == 'BitMask("X11X001")'
Exemple #5
0
def test_general_setting():
    bitmask = BitMask("XXX01")
    assert 1 == bitmask.apply(2)
Exemple #6
0
def test_setting_single_but_to_0():
    bitmask = BitMask("XXX0X")

    assert 1 == bitmask.apply(3)
def test_runner_calls_mask():
    memory = DummyMemory()
    runner = Runner(memory)

    runner.execute("mask = XX10X")
    assert BitMask("XX10X") == memory.mask