From 4772c14d125f61e0f78107f686d24ac72bd72d7c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 10 Aug 2018 15:16:41 -0400 Subject: [PATCH] Add async tests from prototype --- tests/012_async.ts | 11 +++++++++++ tests/012_async.ts.out | 3 +++ tests/async_error.ts | 9 +++++++++ tests/async_error.ts.out | 10 ++++++++++ 4 files changed, 33 insertions(+) create mode 100644 tests/012_async.ts create mode 100644 tests/012_async.ts.out create mode 100644 tests/async_error.ts create mode 100644 tests/async_error.ts.out diff --git a/tests/012_async.ts b/tests/012_async.ts new file mode 100644 index 0000000000..57ae355c25 --- /dev/null +++ b/tests/012_async.ts @@ -0,0 +1,11 @@ +// Check that we can use the async keyword. +async function main() { + await new Promise((resolve, reject) => { + console.log("2"); + setTimeout(resolve, 100); + }); + console.log("3"); +} + +console.log("1"); +main(); diff --git a/tests/012_async.ts.out b/tests/012_async.ts.out new file mode 100644 index 0000000000..01e79c32a8 --- /dev/null +++ b/tests/012_async.ts.out @@ -0,0 +1,3 @@ +1 +2 +3 diff --git a/tests/async_error.ts b/tests/async_error.ts new file mode 100644 index 0000000000..12dee11eb0 --- /dev/null +++ b/tests/async_error.ts @@ -0,0 +1,9 @@ + +console.log("hello"); +const foo = async () => { + console.log("before error"); + throw Error("error"); +} + +foo(); +console.log("world"); diff --git a/tests/async_error.ts.out b/tests/async_error.ts.out new file mode 100644 index 0000000000..1290629b17 --- /dev/null +++ b/tests/async_error.ts.out @@ -0,0 +1,10 @@ +hello +before error +Error: error + at foo ([WILDCARD]tests/async_error.ts:5:9) + at eval ([WILDCARD]tests/async_error.ts:8:1) + at eval () + at execute (deno/js/runtime.ts:[WILDCARD]) + at FileModule.compileAndRun (deno/js/runtime.ts:[WILDCARD]) + at denoMain (deno/js/main.ts:[WILDCARD]) + at deno_main.js:1:1