|
1 | 1 | import { ModuleKind, ScriptTarget } from "typescript"; |
2 | 2 | import { LuaTarget } from "../../../src"; |
3 | | -import { unsupportedForTargetButOverrideAvailable } from "../../../src/transformation/utils/diagnostics"; |
4 | | -import { awaitMustBeInAsyncFunction } from "../../../src/transformation/utils/diagnostics"; |
| 3 | +import { |
| 4 | + awaitMustBeInAsyncFunction, |
| 5 | + unsupportedAsyncGenerator, |
| 6 | + unsupportedForAwaitOf, |
| 7 | + unsupportedForTargetButOverrideAvailable, |
| 8 | +} from "../../../src/transformation/utils/diagnostics"; |
5 | 9 | import * as util from "../../util"; |
6 | 10 |
|
7 | 11 | const promiseTestLib = ` |
@@ -1123,3 +1127,28 @@ describe("try/catch in async function", () => { |
1123 | 1127 | .expectToEqual(["finally", "ok"]); |
1124 | 1128 | }); |
1125 | 1129 | }); |
| 1130 | + |
| 1131 | +describe("async generators are unsupported", () => { |
| 1132 | + test.each([ |
| 1133 | + "async function* gen() { yield 1; }", |
| 1134 | + "const gen = async function*() { yield 1; };", |
| 1135 | + "const gen = { async *m() { yield 1; } };", |
| 1136 | + "class C { async *m() { yield 1; } }", |
| 1137 | + ])("diagnoses %p", source => { |
| 1138 | + util.testModule` |
| 1139 | + ${source} |
| 1140 | + export {} |
| 1141 | + `.expectToHaveDiagnostics([unsupportedAsyncGenerator.code]); |
| 1142 | + }); |
| 1143 | +}); |
| 1144 | + |
| 1145 | +test("for-await-of is unsupported", () => { |
| 1146 | + util.testModule` |
| 1147 | + async function run(items: AsyncIterable<number>) { |
| 1148 | + for await (const x of items) { |
| 1149 | + void x; |
| 1150 | + } |
| 1151 | + } |
| 1152 | + export {} |
| 1153 | + `.expectToHaveDiagnostics([unsupportedForAwaitOf.code]); |
| 1154 | +}); |
0 commit comments