MCPcopy Create free account
hub / github.com/Distributive-Network/PythonMonkey / test_webassembly

Function test_webassembly

tests/python/test_event_loop.py:412–435  ·  view source on GitHub ↗

Tests for off-thread promises

()

Source from the content-addressed store, hash-verified

410
411
412def test_webassembly():
413 """
414 Tests for off-thread promises
415 """
416 async def async_fn():
417 # off-thread promises can run
418 assert 'instantiated' == await pm.eval("""
419 // https://github.com/mdn/webassembly-examples/blob/main/js-api-examples/simple.wasm
420 var code = new Uint8Array([
421 0, 97, 115, 109, 1, 0, 0, 0, 1, 8, 2, 96,
422 1, 127, 0, 96, 0, 0, 2, 25, 1, 7, 105, 109,
423 112, 111, 114, 116, 115, 13, 105, 109, 112, 111, 114, 116,
424 101, 100, 95, 102, 117, 110, 99, 0, 0, 3, 2, 1,
425 1, 7, 17, 1, 13, 101, 120, 112, 111, 114, 116, 101,
426 100, 95, 102, 117, 110, 99, 0, 1, 10, 8, 1, 6,
427 0, 65, 42, 16, 0, 11
428 ]);
429
430 WebAssembly.instantiate(code, { imports: { imported_func() {} } }).then(() => 'instantiated')
431 """)
432
433 # making sure the async_fn is run
434 return True
435 assert asyncio.run(async_fn())

Callers

nothing calls this directly

Calls 1

async_fnFunction · 0.70

Tested by

no test coverage detected