mirror of
https://github.com/nodejs/node.git
synced 2025-05-04 04:43:16 +00:00

Partition test/addons-napi into test/js-native-api and test/node-api to isolate the Node.js-agnostic portion of the N-API tests from the Node.js-specific portion. PR-URL: https://github.com/nodejs/node/pull/24557 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
26 lines
683 B
JavaScript
26 lines
683 B
JavaScript
'use strict';
|
|
// Flags: --expose-gc
|
|
|
|
const common = require('../../common');
|
|
const assert = require('assert');
|
|
const test = require(`./build/${common.buildType}/binding`);
|
|
|
|
assert.strictEqual(test.finalizeCount, 0);
|
|
(() => {
|
|
const obj = test.createObject(10);
|
|
assert.strictEqual(obj.plusOne(), 11);
|
|
assert.strictEqual(obj.plusOne(), 12);
|
|
assert.strictEqual(obj.plusOne(), 13);
|
|
})();
|
|
global.gc();
|
|
assert.strictEqual(test.finalizeCount, 1);
|
|
|
|
(() => {
|
|
const obj2 = test.createObject(20);
|
|
assert.strictEqual(obj2.plusOne(), 21);
|
|
assert.strictEqual(obj2.plusOne(), 22);
|
|
assert.strictEqual(obj2.plusOne(), 23);
|
|
})();
|
|
global.gc();
|
|
assert.strictEqual(test.finalizeCount, 2);
|