diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/018_async_catch.ts | 14 | ||||
-rw-r--r-- | tests/018_async_catch.ts.out | 3 | ||||
-rw-r--r-- | tests/async_error.ts.out | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/tests/018_async_catch.ts b/tests/018_async_catch.ts new file mode 100644 index 000000000..b073654d9 --- /dev/null +++ b/tests/018_async_catch.ts @@ -0,0 +1,14 @@ +async function fn() { + throw new Error("message"); +} +async function call() { + try { + console.log("before await fn()"); + await fn(); + console.log("after await fn()"); + } catch (error) { + console.log("catch"); + } + console.log("after try-catch"); +} +call().catch(() => console.log("outer catch")); diff --git a/tests/018_async_catch.ts.out b/tests/018_async_catch.ts.out new file mode 100644 index 000000000..4fc219973 --- /dev/null +++ b/tests/018_async_catch.ts.out @@ -0,0 +1,3 @@ +before await fn() +catch +after try-catch diff --git a/tests/async_error.ts.out b/tests/async_error.ts.out index 862cf0f96..69be815a0 100644 --- a/tests/async_error.ts.out +++ b/tests/async_error.ts.out @@ -1,5 +1,6 @@ hello before error +world Error: error at foo ([WILDCARD]tests/async_error.ts:4:9) at eval ([WILDCARD]tests/async_error.ts:7:1) |