Skip to content

Commit 200564e

Browse files
committed
Improve async iteration test
1 parent d39bd6d commit 200564e

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
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/pure/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "../tsconfig.json",
33
"include": ["./**/*.ts"],
4-
"exclude": ["./async-iteration.test.ts"],
4+
"exclude": ["async-iteration.test.ts"],
55
"compilerOptions": {
66
"types": ["@core-js/types/pure"]
77
}

tests/type-definitions/runner.mjs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ async function prepareEnvironment(environments, coreJsTypes) {
111111
await writeJson(path.join(tmpEnvDir, `tsconfig.${ type }.json`), {
112112
extends: '../../tsconfig.json',
113113
include: [`../../${ type }/**/*.ts`],
114+
exclude: [`../../${ type }/async-iteration.test.ts`],
114115
});
115116
}
116117
}
@@ -122,12 +123,12 @@ await $`npx -p typescript@5.9 tsc -p tsconfig.entries.json`;
122123
await $`npx -p typescript@5.9 tsc -p tsconfig.entries.pure.json`;
123124
await $`npx -p typescript@5.9 -p @types/node@24 tsc -p tsconfig.templates.require.json`;
124125

125-
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

131+
if (!ALL_TESTS) {
131132
await $`npx -p typescript@5.6 tsc -p pure/tsconfig.json --target es6 --lib es6`;
132133
await $`npx -p typescript@5.6 tsc -p pure/tsconfig.json --target esnext --lib esnext`;
133134
await $`npx -p typescript@5.6 tsc -p global/tsconfig.json --target es6 --lib es6,dom`;
@@ -146,8 +147,4 @@ if (!ALL_TESTS) {
146147
await clearTmpDir();
147148
echo(`Tested: ${ chalk.green(tested) }, Failed: ${ chalk.red(failed) }`);
148149
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`;
153150
}

0 commit comments

Comments
 (0)