summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/012_async.ts11
-rw-r--r--tests/012_async.ts.out3
-rw-r--r--tests/async_error.ts9
-rw-r--r--tests/async_error.ts.out10
4 files changed, 33 insertions, 0 deletions
diff --git a/tests/012_async.ts b/tests/012_async.ts
new file mode 100644
index 000000000..57ae355c2
--- /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 000000000..01e79c32a
--- /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 000000000..12dee11eb
--- /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 000000000..1290629b1
--- /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 (<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