From 8c9f91908b83cd35578b6abc843fba071825037d Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Fri, 28 Jun 2024 19:39:37 +0100 Subject: [PATCH] test: use `Set.difference()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/nodejs/node/pull/53597 Refs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/difference Reviewed-By: Luigi Pinca Reviewed-By: Chemi Atlow Reviewed-By: Michaƫl Zasso Reviewed-By: Benjamin Gruenbaum Reviewed-By: Marco Ippolito --- test/parallel/test-bootstrap-modules.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-bootstrap-modules.js b/test/parallel/test-bootstrap-modules.js index a21c514d44c382..71e2854f8e2d47 100644 --- a/test/parallel/test-bootstrap-modules.js +++ b/test/parallel/test-bootstrap-modules.js @@ -170,10 +170,6 @@ if (process.env.NODE_V8_COVERAGE) { expected.atRunTime.add('Internal Binding profiler'); } -const difference = (setA, setB) => { - return new Set([...setA].filter((x) => !setB.has(x))); -}; - // Accumulate all the errors and print them at the end instead of throwing // immediately which makes it harder to update the test. const errorLogs = []; @@ -187,8 +183,8 @@ function err(message) { } if (common.isMainThread) { - const missing = difference(expected.beforePreExec, actual.beforePreExec); - const extra = difference(actual.beforePreExec, expected.beforePreExec); + const missing = expected.beforePreExec.difference(actual.beforePreExec); + const extra = actual.beforePreExec.difference(expected.beforePreExec); if (missing.size !== 0) { err('These builtins are now no longer loaded before pre-execution.'); err('If this is intentional, remove them from `expected.beforePreExec`.'); @@ -222,8 +218,8 @@ if (!common.isMainThread) { } { - const missing = difference(expected.atRunTime, actual.atRunTime); - const extra = difference(actual.atRunTime, expected.atRunTime); + const missing = expected.atRunTime.difference(actual.atRunTime); + const extra = actual.atRunTime.difference(expected.atRunTime); if (missing.size !== 0) { err('These builtins are now no longer loaded at run time.'); err('If this is intentional, remove them from `expected.atRunTime`.');