aboutsummaryrefslogtreecommitdiff
path: root/test/js/async_try_catch_expression.t.js
diff options
context:
space:
mode:
authorDmitry Volyntsev <xeioex@nginx.com>2022-05-31 21:48:46 -0700
committerDmitry Volyntsev <xeioex@nginx.com>2022-05-31 21:48:46 -0700
commitc62a9fb92b102c90a66aa724cb9054183a33a68c (patch)
treed497f766cf46ce9b5a80e90c7a03996a962aaa07 /test/js/async_try_catch_expression.t.js
parent83bb129f10cf54ab5dc5c1c1ac3a071133143714 (diff)
downloadnjs-c62a9fb92b102c90a66aa724cb9054183a33a68c.tar.gz
njs-c62a9fb92b102c90a66aa724cb9054183a33a68c.zip
Fixed catching of the exception thrown from an awaited function.
This closes #500 issue on Github.
Diffstat (limited to 'test/js/async_try_catch_expression.t.js')
-rw-r--r--test/js/async_try_catch_expression.t.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/js/async_try_catch_expression.t.js b/test/js/async_try_catch_expression.t.js
new file mode 100644
index 00000000..58d04203
--- /dev/null
+++ b/test/js/async_try_catch_expression.t.js
@@ -0,0 +1,28 @@
+/*---
+includes: [compareArray.js]
+flags: [async]
+---*/
+
+let stages = [];
+
+async function af() {
+ try {
+ await ({}).a.a();
+
+ $DONOTEVALUATE();
+ }
+ catch (v) {
+ stages.push('catch');
+ }
+ finally {
+ stages.push('finally');
+ }
+
+ return "end";
+};
+
+af().then(v => {
+ stages.push(v);
+ assert.compareArray(stages, ['catch', 'finally', 'end']);
+})
+.then($DONE, $DONE)