diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/run_tests.rs | 6 | ||||
-rw-r--r-- | cli/tests/testdata/error_for_await.ts | 14 | ||||
-rw-r--r-- | cli/tests/testdata/error_for_await.ts.out | 10 |
3 files changed, 30 insertions, 0 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 88aff0986..14e0e1241 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -622,6 +622,12 @@ itest!(error_026_remote_import_error { http_server: true, }); +itest!(error_for_await { + args: "run --reload error_for_await.ts", + output: "error_for_await.ts.out", + exit_code: 1, +}); + itest!(error_missing_module_named_import { args: "run --reload error_missing_module_named_import.ts", output: "error_missing_module_named_import.ts.out", diff --git a/cli/tests/testdata/error_for_await.ts b/cli/tests/testdata/error_for_await.ts new file mode 100644 index 000000000..6e8c5203f --- /dev/null +++ b/cli/tests/testdata/error_for_await.ts @@ -0,0 +1,14 @@ +const listener = Deno.listen({ port: 8080 }); + +for await (const conn of listener) { + handleConn(conn); +} + +function handleConn(conn: Deno.Conn) { + const httpConn = Deno.serveHttp(conn); + for await (const event of httpConn) { + event.respondWith(new Response("html", { status: 200 })); + } +} + +export {}; diff --git a/cli/tests/testdata/error_for_await.ts.out b/cli/tests/testdata/error_for_await.ts.out new file mode 100644 index 000000000..db3cdecb4 --- /dev/null +++ b/cli/tests/testdata/error_for_await.ts.out @@ -0,0 +1,10 @@ +[WILDCARD] +error: TS1103 [ERROR]: 'for await' loops are only allowed within async functions and at the top levels of modules. + for await (const event of httpConn) { + ~~~~~ + at [WILDCARD]error_for_await.ts:9:7 + +TS1356 [ERROR]: Did you mean to mark this function as 'async'? + function handleConn(conn: Deno.Conn) { + ~~~~~~~~~~ + at [WILDCARD]error_for_await.ts:7:10 |