Skip to content

Commit

Permalink
Add async tests from prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Aug 11, 2018
1 parent c7ce450 commit 4772c14
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/012_async.ts
Original file line number Diff line number Diff line change
@@ -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();
3 changes: 3 additions & 0 deletions tests/012_async.ts.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1
2
3
9 changes: 9 additions & 0 deletions tests/async_error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

console.log("hello");
const foo = async () => {
console.log("before error");
throw Error("error");
}

foo();
console.log("world");
10 changes: 10 additions & 0 deletions tests/async_error.ts.out
Original file line number Diff line number Diff line change
@@ -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 (<anonymous>)
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

0 comments on commit 4772c14

Please sign in to comment.