コード例 #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)