mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
Add async tests from prototype
This commit is contained in:
parent
c7ce450ee9
commit
4772c14d12
4 changed files with 33 additions and 0 deletions
11
tests/012_async.ts
Normal file
11
tests/012_async.ts
Normal file
|
@ -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
tests/012_async.ts.out
Normal file
3
tests/012_async.ts.out
Normal file
|
@ -0,0 +1,3 @@
|
|||
1
|
||||
2
|
||||
3
|
9
tests/async_error.ts
Normal file
9
tests/async_error.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
|
||||
console.log("hello");
|
||||
const foo = async () => {
|
||||
console.log("before error");
|
||||
throw Error("error");
|
||||
}
|
||||
|
||||
foo();
|
||||
console.log("world");
|
10
tests/async_error.ts.out
Normal file
10
tests/async_error.ts.out
Normal file
|
@ -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
|
Loading…
Reference in a new issue