aboutsummaryrefslogtreecommitdiff
path: root/test/js
diff options
context:
space:
mode:
Diffstat (limited to 'test/js')
-rw-r--r--test/js/async_try_catch_call.t.js29
-rw-r--r--test/js/async_try_catch_expression.t.js28
2 files changed, 57 insertions, 0 deletions
diff --git a/test/js/async_try_catch_call.t.js b/test/js/async_try_catch_call.t.js
new file mode 100644
index 00000000..6e8ef104
--- /dev/null
+++ b/test/js/async_try_catch_call.t.js
@@ -0,0 +1,29 @@
+/*---
+includes: [compareArray.js]
+flags: [async]
+---*/
+
+let stages = [];
+const fn = async () => { throw new Error('Oops') };
+
+async function af() {
+ try {
+ await fn();
+
+ $DONOTEVALUATE();
+ }
+ catch (v) {
+ stages.push(`catch:${v}`);
+ }
+ finally {
+ stages.push('finally');
+ }
+
+ return "end";
+};
+
+af().then(v => {
+ stages.push(v);
+ assert.compareArray(stages, ['catch:Error: Oops', 'finally', 'end']);
+})
+.then($DONE, $DONE)
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)