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