From 45d3b8955de628db0ef051eeb8e351837b4a3b3e Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Fri, 12 Oct 2018 11:22:52 -0700 Subject: Fix promise reject issue (#936) --- tests/018_async_catch.ts | 14 ++++++++++++++ tests/018_async_catch.ts.out | 3 +++ tests/async_error.ts.out | 1 + 3 files changed, 18 insertions(+) create mode 100644 tests/018_async_catch.ts create mode 100644 tests/018_async_catch.ts.out (limited to 'tests') 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) -- cgit v1.2.3