mirror of
https://github.com/nodejs/node.git
synced 2026-12-05 00:48:58 -05:00
The string literal messages in addons-napi/test_buffer/test.js are less helpful than the default messages, so use the default messages. PR-URL: https://github.com/nodejs/node/pull/16808 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
23 lines
839 B
JavaScript
23 lines
839 B
JavaScript
'use strict';
|
|
// Flags: --expose-gc
|
|
|
|
const common = require('../../common');
|
|
const binding = require(`./build/${common.buildType}/test_buffer`);
|
|
const assert = require('assert');
|
|
|
|
assert.strictEqual(binding.newBuffer().toString(), binding.theText);
|
|
assert.strictEqual(binding.newExternalBuffer().toString(), binding.theText);
|
|
console.log('gc1');
|
|
global.gc();
|
|
assert.strictEqual(binding.getDeleterCallCount(), 1, 'deleter was not called');
|
|
assert.strictEqual(binding.copyBuffer().toString(), binding.theText);
|
|
|
|
let buffer = binding.staticBuffer();
|
|
assert.strictEqual(binding.bufferHasInstance(buffer), true,
|
|
'buffer type checking fails');
|
|
assert.strictEqual(binding.bufferInfo(buffer), true);
|
|
buffer = null;
|
|
global.gc();
|
|
console.log('gc2');
|
|
assert.strictEqual(binding.getDeleterCallCount(), 2, 'deleter was not called');
|