コード例 #1
0
def test_vm_mem_alloc():
    code = create_instr("alloc", 0)
    vm = Arkhe(code)
    vm.registers[0] = 16
    vm.exc_instr()
    assert len(vm.memory) == 16
    vm.counter = 0
    vm.exc_instr()
    assert len(vm.memory) == 32
コード例 #2
0
def test_vm_mem_read():
    code = create_instr("read", 0, 1)
    vm = Arkhe(code)
    vm.registers[0] = 16
    with pytest.raises(MemoryFault):
        vm.exc_instr()
    vm.memory.alloc(100)
    vm.memory[16] = "hello"
    vm.counter = 0
    vm.exc_instr()
    assert vm.registers[1] == "hello"