1'use strict';
2const common = require('../../common');
3const path = require('path');
4const assert = require('assert');
5const { Worker } = require('worker_threads');
6const binding = path.resolve(__dirname, `./build/${common.buildType}/binding`);
7const { getFreeCallCount } = require(binding);
8
9// Test that buffers allocated with a free callback through our APIs are
10// released when a Worker owning it exits.
11
12const w = new Worker(`require(${JSON.stringify(binding)})`, { eval: true });
13
14assert.strictEqual(getFreeCallCount(), 0);
15w.on('exit', common.mustCall(() => {
16  assert.strictEqual(getFreeCallCount(), 1);
17}));
18