summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/finalization_registry.js
blob: f75979358ee9aa8921349559f7f7023839bb5e74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
"use strict";

function assertEquals(a, b) {
  if (a === b) return;
  throw a + " does not equal " + b;
}

const registry = new FinalizationRegistry((value) => {
  assertEquals(value, "called!");
  Deno.core.print("FinalizationRegistry called!\n");
});

(function () {
  let x = {};
  registry.register(x, "called!");
  x = null;
})();

gc();