Skip to content

Commit 02bd866

Browse files
authored
test: use Set.difference()
Starting from V8 12.2 and Node.js 22, the built-in `Set` object now has a `difference()` method. Replace our implementation of Set difference in `parallel/test-bootstrap-modules` with the built-in method. PR-URL: #53597 Refs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
1 parent f5ed338 commit 02bd866

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

test/parallel/test-bootstrap-modules.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ if (process.env.NODE_V8_COVERAGE) {
170170
expected.atRunTime.add('Internal Binding profiler');
171171
}
172172

173-
const difference = (setA, setB) => {
174-
return new Set([...setA].filter((x) => !setB.has(x)));
175-
};
176-
177173
// Accumulate all the errors and print them at the end instead of throwing
178174
// immediately which makes it harder to update the test.
179175
const errorLogs = [];
@@ -187,8 +183,8 @@ function err(message) {
187183
}
188184

189185
if (common.isMainThread) {
190-
const missing = difference(expected.beforePreExec, actual.beforePreExec);
191-
const extra = difference(actual.beforePreExec, expected.beforePreExec);
186+
const missing = expected.beforePreExec.difference(actual.beforePreExec);
187+
const extra = actual.beforePreExec.difference(expected.beforePreExec);
192188
if (missing.size !== 0) {
193189
err('These builtins are now no longer loaded before pre-execution.');
194190
err('If this is intentional, remove them from `expected.beforePreExec`.');
@@ -222,8 +218,8 @@ if (!common.isMainThread) {
222218
}
223219

224220
{
225-
const missing = difference(expected.atRunTime, actual.atRunTime);
226-
const extra = difference(actual.atRunTime, expected.atRunTime);
221+
const missing = expected.atRunTime.difference(actual.atRunTime);
222+
const extra = actual.atRunTime.difference(expected.atRunTime);
227223
if (missing.size !== 0) {
228224
err('These builtins are now no longer loaded at run time.');
229225
err('If this is intentional, remove them from `expected.atRunTime`.');

0 commit comments

Comments
 (0)