summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ports/webassembly/run_python_async_error.mjs11
-rw-r--r--tests/ports/webassembly/run_python_async_error.mjs.exp5
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/ports/webassembly/run_python_async_error.mjs b/tests/ports/webassembly/run_python_async_error.mjs
new file mode 100644
index 000000000..ce4db0ff0
--- /dev/null
+++ b/tests/ports/webassembly/run_python_async_error.mjs
@@ -0,0 +1,11 @@
+// Test raising an exception in async Python code running in runPythonAsync,
+// that the JavaScript-level promise is rejected with a PythonError.
+
+const mp = await (await import(process.argv[2])).loadMicroPython();
+
+try {
+ await mp.runPythonAsync("await fail");
+} catch (error) {
+ console.log(error.name, error.type);
+ console.log(error.message);
+}
diff --git a/tests/ports/webassembly/run_python_async_error.mjs.exp b/tests/ports/webassembly/run_python_async_error.mjs.exp
new file mode 100644
index 000000000..c77de4bb3
--- /dev/null
+++ b/tests/ports/webassembly/run_python_async_error.mjs.exp
@@ -0,0 +1,5 @@
+PythonError NameError
+Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+NameError: name 'fail' isn't defined
+