def test_next_count(VMMock):
    vm = jollypy.JollyVM()
    interactive_jolly = ijolly.InteractiveJolly(vm)

    interactive_jolly.next(5)

    assert vm.execute_instruction.call_count == 5
Ejemplo n.º 2
0
def test_extract_memory_to_string_0_5_decimal():
    watcher = ijolly.MemoryWatcher("foo", 0, 5)
    interactive_jolly = ijolly.InteractiveJolly(None)
    interactive_jolly.switch_to_decimal()
    type(interactive_jolly).memory = PropertyMock(
        return_value=[1, 2, 3, 4, 5, 6, 7, 8])

    assert watcher.extract_memory_to_string(interactive_jolly) == '1 2 3 4 5'
Ejemplo n.º 3
0
def test_to_user_string_42_5_hexadecimal():
    watcher = ijolly.MemoryWatcher("foo", 42, 5)
    interactive_jolly = ijolly.InteractiveJolly(None)
    interactive_jolly.switch_to_hexadecimal()
    type(interactive_jolly).memory = PropertyMock(
        return_value=[x for x in range(0, 100)])

    assert watcher.to_user_string(
        interactive_jolly) == '"foo" 0x0000002a: 2a 2b 2c 2d 2e'
Ejemplo n.º 4
0
def test_to_user_string_0_5_hexadecimal():
    watcher = ijolly.MemoryWatcher("foo", 0, 5)
    interactive_jolly = ijolly.InteractiveJolly(None)
    interactive_jolly.switch_to_hexadecimal()
    type(interactive_jolly).memory = PropertyMock(
        return_value=[1, 2, 3, 4, 5, 6, 7, 8])

    assert watcher.to_user_string(
        interactive_jolly) == '"foo" 0x00000000: 01 02 03 04 05'
Ejemplo n.º 5
0
def test_extract_memory_to_string_42_5_decimal():
    watcher = ijolly.MemoryWatcher("foo", 42, 5)
    interactive_jolly = ijolly.InteractiveJolly(None)
    interactive_jolly.switch_to_decimal()
    type(interactive_jolly).memory = PropertyMock(
        return_value=[x for x in range(0, 100)])

    assert watcher.extract_memory_to_string(
        interactive_jolly) == '42 43 44 45 46'
Ejemplo n.º 6
0
def test_parse_input_string():
    interactive_jolly = ijolly.InteractiveJolly(None)
    shell = ijolly.JollyShell(interactive_jolly)

    assert shell.parse_input("foo") == "foo"
Ejemplo n.º 7
0
def test_parse_input_42_hex():
    interactive_jolly = ijolly.InteractiveJolly(None)
    shell = ijolly.JollyShell(interactive_jolly)

    assert shell.parse_input("0x2a") == 42
Ejemplo n.º 8
0
def test_parse_input_pc():
    interactive_jolly = ijolly.InteractiveJolly(None)
    type(interactive_jolly).pc_address = PropertyMock(return_value=42)
    shell = ijolly.JollyShell(interactive_jolly)

    assert shell.parse_input("pc") == 42
def test_switch_to_hexadecimal():
    interactive_jolly = ijolly.InteractiveJolly(None)
    interactive_jolly.switch_to_decimal()
    interactive_jolly.switch_to_hexadecimal()

    assert type(interactive_jolly.integer_print_strategy) is ijolly.IntegerToHexString
def test_default_printing_strategy_is_hex():
    interactive_jolly = ijolly.InteractiveJolly(None)

    assert type(interactive_jolly.integer_print_strategy) is ijolly.IntegerToHexString