예제 #1
0
    def test_hello_world(self):
        instance = Instance(TEST_BYTES)
        pointer = instance.call('string')
        memory = instance.uint8_memory_view(pointer)
        nth = 0
        string = ''

        while (0 != memory[nth]):
            string += chr(memory[nth])
            nth += 1

        self.assertEqual(string, 'Hello, World!')
예제 #2
0
from wasmer import Instance, Value
import os

__dir__ = os.path.dirname(os.path.realpath(__file__))

wasm_bytes = open(__dir__ + '/memory.wasm', 'rb').read()
instance = Instance(wasm_bytes)
pointer = instance.call('return_hello')

memory = instance.uint8_memory_view(pointer)
nth = 0;
string = '';

while (0 != memory[nth]):
    string += chr(memory[nth])
    nth += 1

print('"' + string + '"') # "Hello, World!"