Beispiel #1
0
def test_i32_operand():
    assert parse_operand(I32(0x45671234)) == Immediate(0x45671234, 4)
Beispiel #2
0
def test_none_returns_inherent_addressing_mode():
    operand = None
    r = parse_operand(operand)
    assert isinstance(r, Inherent)
Beispiel #3
0
def test_i16_operand():
    assert parse_operand(I16(-4567)) == Immediate(60969, 2)
Beispiel #4
0
def test_set_with_three_byte_value_raises_value_error():
    address = 0x010000
    operand = {address}
    with raises(ValueError):
        parse_operand(operand)
Beispiel #5
0
def test_set_with_string_raises_type_error():
    address = 'hello'
    operand = {address}
    with raises(TypeError):
        parse_operand(operand)
Beispiel #6
0
def test_empty_set_raises_value_error():
    operand = set()
    with raises(ValueError):
        parse_operand(operand)
Beispiel #7
0
def test_set_with_two_byte_value_returns_extended_direct_addressing_mode():
    operand = {0x1C48}
    r = parse_operand(operand)
    assert isinstance(r, ExtendedDirect)
Beispiel #8
0
def test_unsupported_tuple_items_raises_type_error():
    with raises(TypeError):
        parse_operand(("some", "strings"))
Beispiel #9
0
def test_unsupported_tuple_indexed_offset_raises_type_error():
    with raises(TypeError):
        parse_operand({"some": "strings"})
Beispiel #10
0
def test_empty_bytes_operand_raises_value_error():
    with raises(ValueError):
        assert parse_operand(b'')
Beispiel #11
0
def test_multi_bytes_operand_raises_value_error(b):
    with raises(ValueError):
        assert parse_operand(b)
Beispiel #12
0
def test_bytes_operand_gives_immediate_value(b):
    assert parse_operand(b) == Immediate(b[0], 1)
Beispiel #13
0
def test_value_stored_in_immediate_addressing_mode():
    operand = 0x42
    r = parse_operand(operand)
    assert r.value == operand
Beispiel #14
0
def test_bare_integer_returns_immediate_addressing_mode():
    operand = 0x30
    r = parse_operand(operand)
    assert isinstance(r, Immediate)
Beispiel #15
0
def test_address_stored_in_page_direct_addressing_mode():
    address = 0x78
    operand = {address}
    r = parse_operand(operand)
    assert r.address == address
Beispiel #16
0
def test_unsupported_tuple_indexed_base_raises_type_error():
    with raises(TypeError):
        parse_operand({2: "strings"})
Beispiel #17
0
def test_set_with_negative_address_raises_value_error():
    operand = {-1}
    with raises(ValueError):
        parse_operand(operand)
Beispiel #18
0
def test_u8_operand():
    assert parse_operand(U8(42)) == Immediate(42, 1)
Beispiel #19
0
def test_set_with_multiple_items_raises_value_error():
    operand = {0x1C, 0xD5}
    with raises(ValueError):
        parse_operand(operand)
Beispiel #20
0
def test_u16_operand():
    assert parse_operand(U16(0x4567)) == Immediate(0x4567, 2)
Beispiel #21
0
def test_address_stored_in_extended_direct_addressing_mode():
    address = 0xD58A
    operand = {address}
    r = parse_operand(operand)
    assert r.address == address
Beispiel #22
0
def test_set_with_one_byte_value_returns_page_direct_addressing_mode():
    operand = {0x30}
    r = parse_operand(operand)
    assert isinstance(r, PageDirect)
Beispiel #23
0
def test_set_with_label_returns_extended_direct_addressing_mode():
    address = Label('loop')
    operand = {address}
    r = parse_operand(operand)
    assert r.address == address
Beispiel #24
0
def test_i8_operand():
    assert parse_operand(I8(-42)) == Immediate(214, 1)
Beispiel #25
0
def test_list_causes_indirection_for_integer_address():
    address = 0x3560
    operand = [{address}]
    r = parse_operand(operand)
    assert isinstance(r, ExtendedIndirect)
Beispiel #26
0
def test_list_causes_indirection_for_label():
    address = Label('loop')
    operand = [{address}]
    r = parse_operand(operand)
    assert isinstance(r, ExtendedIndirect)