summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ports/webassembly/run_python_async_no_await.mjs24
-rw-r--r--tests/ports/webassembly/run_python_async_no_await.mjs.exp6
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/ports/webassembly/run_python_async_no_await.mjs b/tests/ports/webassembly/run_python_async_no_await.mjs
new file mode 100644
index 000000000..19462d6e7
--- /dev/null
+++ b/tests/ports/webassembly/run_python_async_no_await.mjs
@@ -0,0 +1,24 @@
+// Test runPythonAsync() without await'ing it.
+
+const mp = await (await import(process.argv[2])).loadMicroPython();
+
+globalThis.p = new Promise((resolve, reject) => {
+ setTimeout(() => {
+ resolve(123);
+ console.log("setTimeout resolved");
+ }, 100);
+});
+
+console.log(1);
+
+const ret = mp.runPythonAsync(`
+import js
+print("py 1")
+print("resolved value:", await js.p)
+print("py 2")
+`);
+
+// `ret` should be a Promise.
+console.log(2, ret);
+
+// Here, the Python async code should continue to run until completed.
diff --git a/tests/ports/webassembly/run_python_async_no_await.mjs.exp b/tests/ports/webassembly/run_python_async_no_await.mjs.exp
new file mode 100644
index 000000000..1dbf7f95f
--- /dev/null
+++ b/tests/ports/webassembly/run_python_async_no_await.mjs.exp
@@ -0,0 +1,6 @@
+1
+2 Promise { <pending> }
+py 1
+setTimeout resolved
+resolved value: 123
+py 2