summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/finalization_registry.js
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/testdata/finalization_registry.js')
-rw-r--r--cli/tests/testdata/finalization_registry.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/cli/tests/testdata/finalization_registry.js b/cli/tests/testdata/finalization_registry.js
new file mode 100644
index 000000000..f75979358
--- /dev/null
+++ b/cli/tests/testdata/finalization_registry.js
@@ -0,0 +1,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();