Skip to content

Commit a0f963b

Browse files
committed
refactor: simplify deduplicateLabels and clarify resolveDatasets fallback
1 parent bf3c93c commit a0f963b

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

packages/phpunit/src/Interpreter/Resolvers/PestResolver.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ function resolveDatasets(sources: AstNode[]): string[] {
134134
return cartesianProduct(datasets);
135135
}
136136

137+
// Cartesian failed (e.g. closure/generator can't be statically resolved); fall back to independent resolution
137138
return sources.flatMap((source) => resolvePestLabels(source));
138139
}
139140

@@ -168,20 +169,13 @@ function deduplicateLabels(labels: string[]): string[] {
168169
counts.set(label, (counts.get(label) ?? 0) + 1);
169170
}
170171

171-
const duplicates = new Set<string>();
172-
for (const [label, count] of counts) {
173-
if (count > 1) {
174-
duplicates.add(label);
175-
}
176-
}
177-
178-
if (duplicates.size === 0) {
172+
if ([...counts.values()].every((c) => c === 1)) {
179173
return labels;
180174
}
181175

182176
const indices = new Map<string, number>();
183177
return labels.map((label) => {
184-
if (!duplicates.has(label)) {
178+
if ((counts.get(label) ?? 0) <= 1) {
185179
return label;
186180
}
187181
const idx = (indices.get(label) ?? 0) + 1;

0 commit comments

Comments
 (0)