forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: checks on napi factory wrap’s finalization
Fixes: nodejs#22396 PR-URL: nodejs#22612 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gabriel Schulhof <[email protected]>
- Loading branch information
1 parent
cf0e881
commit 1cee085
Showing
5 changed files
with
41 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
'use strict'; | ||
// Flags: --expose-gc | ||
|
||
const common = require('../../common'); | ||
const assert = require('assert'); | ||
const createObject = require(`./build/${common.buildType}/binding`); | ||
const test = require(`./build/${common.buildType}/binding`); | ||
|
||
const obj = createObject(10); | ||
assert.strictEqual(obj.plusOne(), 11); | ||
assert.strictEqual(obj.plusOne(), 12); | ||
assert.strictEqual(obj.plusOne(), 13); | ||
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 = createObject(20); | ||
assert.strictEqual(obj2.plusOne(), 21); | ||
assert.strictEqual(obj2.plusOne(), 22); | ||
assert.strictEqual(obj2.plusOne(), 23); | ||
(() => { | ||
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters