Skip to content

Commit 7c7e483

Browse files
committed
Improve async iteration test
1 parent d39bd6d commit 7c7e483

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed
Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
import from from '@core-js/pure/full/async-iterator/from';
2+
import filter from '@core-js/pure/full/async-iterator/filter';
3+
import flatMap from '@core-js/pure/full/async-iterator/flat-map';
4+
import map from '@core-js/pure/full/async-iterator/map';
5+
import take from '@core-js/pure/full/async-iterator/take';
6+
import drop from '@core-js/pure/full/async-iterator/drop';
7+
import toAsync from '@core-js/pure/full/iterator/to-async';
28

39
const aitn = from([1]);
4-
for await (const v of aitn) {
5-
}
10+
for await (const v of aitn) {}
11+
12+
const ait1 = filter(aitn, (v: number, i: number) => v > 0);
13+
for await (const v of ait1) {}
14+
15+
const ait2 = flatMap(aitn, (v: number, i: number) => `${ v }`);
16+
for await (const v of ait2) {}
17+
18+
const ait3 = map(aitn, (v: number, i: number) => v * 2);
19+
for await (const v of ait3) {}
20+
21+
const ait4 = take(aitn, 10);
22+
for await (const v of ait4) {}
23+
24+
const ait5 = drop(aitn, 3);
25+
for await (const v of ait5) {}
26+
27+
declare const itn: Iterator<number>;
28+
const ait6 = toAsync(itn);
29+
for await (const v of ait6) {}

tests/type-definitions/pure/tsconfig.async-iterable.json renamed to tests/type-definitions/pure/tsconfig.async-iteration.json

File renamed without changes.

tests/type-definitions/runner.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ await $`npx -p typescript@5.9 tsc -p tsconfig.entries.pure.json`;
123123
await $`npx -p typescript@5.9 -p @types/node@24 tsc -p tsconfig.templates.require.json`;
124124

125125
if (!ALL_TESTS) {
126-
await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iterable.json --target es2023 --lib es2023`;
127-
await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iterable.json --target esnext --lib esnext`;
128-
await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iterable.json --target es2023 --lib es2023`;
129-
await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iterable.json --target esnext --lib esnext`;
126+
await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iteration.json --target es2023 --lib es2023`;
127+
await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iteration.json --target esnext --lib esnext`;
128+
await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iteration.json --target es2023 --lib es2023`;
129+
await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iteration.json --target esnext --lib esnext`;
130130

131131
await $`npx -p typescript@5.6 tsc -p pure/tsconfig.json --target es6 --lib es6`;
132132
await $`npx -p typescript@5.6 tsc -p pure/tsconfig.json --target esnext --lib esnext`;
@@ -146,8 +146,8 @@ if (!ALL_TESTS) {
146146
await clearTmpDir();
147147
echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`);
148148
if (failed) throw new Error('Some tests have failed');
149-
await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iterable.json --target es2023 --lib es2023`;
150-
await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iterable.json --target esnext --lib esnext`;
151-
await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iterable.json --target es2023 --lib es2023`;
152-
await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iterable.json --target esnext --lib esnext`;
149+
await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iteration.json --target es2023 --lib es2023`;
150+
await $`npx -p typescript@5.6 tsc -p pure/tsconfig.async-iteration.json --target esnext --lib esnext`;
151+
await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iteration.json --target es2023 --lib es2023`;
152+
await $`npx -p typescript@5.9 tsc -p pure/tsconfig.async-iteration.json --target esnext --lib esnext`;
153153
}

0 commit comments

Comments
 (0)