test: make sure weak references are not GCed to early
This fixes flaky util.inspect
tests by making sure that the
inspected WeakMap and WeakSet only contains objects that still have
other hard references. Otherwise the garbage collection could collect
these objects to early.
Refs: https://github.com/nodejs/node/pull/27440#issuecomment-487573000
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines