예제 #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)