diff --git a/tests/012_async.ts b/tests/012_async.ts new file mode 100644 index 00000000000000..57ae355c25f608 --- /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 00000000000000..01e79c32a8c99c --- /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 00000000000000..12dee11eb03200 --- /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 00000000000000..1290629b172d23 --- /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