mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:47:45 +00:00
test-js: Add a mark_as_garbage method to force GC to collect that object
This should fix the flaky tests of test-js. It also fixes the tests when running with the -g flag since the values will not be garbage collected too soon.
This commit is contained in:
parent
3373090993
commit
43b17f27a3
6 changed files with 71 additions and 12 deletions
|
@ -17,10 +17,13 @@ test("invalid values", () => {
|
|||
|
||||
test("automatic removal of garbage-collected values", () => {
|
||||
const weakSet = new WeakSet();
|
||||
{
|
||||
expect(weakSet.add({ a: 1 })).toBe(weakSet);
|
||||
expect(getWeakSetSize(weakSet)).toBe(1);
|
||||
}
|
||||
const item = { a: 1 };
|
||||
|
||||
expect(weakSet.add(item)).toBe(weakSet);
|
||||
expect(getWeakSetSize(weakSet)).toBe(1);
|
||||
|
||||
markAsGarbage("item");
|
||||
gc();
|
||||
|
||||
expect(getWeakSetSize(weakSet)).toBe(0);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue