• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2// Flags: --expose-gc --no-concurrent-array-buffer-sweeping
3
4const common = require('../../common');
5const binding = require(`./build/${common.buildType}/test_buffer`);
6const assert = require('assert');
7const tick = require('util').promisify(require('../../common/tick'));
8
9(async function() {
10  assert.strictEqual(binding.newBuffer().toString(), binding.theText);
11  assert.strictEqual(binding.newExternalBuffer().toString(), binding.theText);
12  console.log('gc1');
13  global.gc();
14  assert.strictEqual(binding.getDeleterCallCount(), 0);
15  await tick(10);
16  assert.strictEqual(binding.getDeleterCallCount(), 1);
17  assert.strictEqual(binding.copyBuffer().toString(), binding.theText);
18
19  let buffer = binding.staticBuffer();
20  assert.strictEqual(binding.bufferHasInstance(buffer), true);
21  assert.strictEqual(binding.bufferInfo(buffer), true);
22  buffer = null;
23  global.gc();
24  assert.strictEqual(binding.getDeleterCallCount(), 1);
25  await tick(10);
26  console.log('gc2');
27  assert.strictEqual(binding.getDeleterCallCount(), 2);
28})().then(common.mustCall());
29