-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
146 additions
and
30 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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var assert = require("assert"); | ||
|
||
var garbageCollect = require("./garbage_collect"); | ||
|
||
function leakTest(Type, getInstance) { | ||
garbageCollect(); | ||
var startSelfFreeingCount = Type.getSelfFreeingInstanceCount(); | ||
var startNonSelfFreeingCount = Type.getNonSelfFreeingConstructedCount(); | ||
|
||
var resolve; | ||
var promise = new Promise(function(_resolve) { resolve = _resolve; }); | ||
|
||
getInstance() | ||
.then(function() { | ||
var selfFreeingCount = Type.getSelfFreeingInstanceCount(); | ||
assert.equal(startSelfFreeingCount + 1, selfFreeingCount); | ||
// get out of this promise chain to help GC get rid of the commit | ||
setTimeout(resolve, 0); | ||
}); | ||
|
||
return promise | ||
.then(function() { | ||
garbageCollect(); | ||
var endSelfFreeingCount = Type.getSelfFreeingInstanceCount(); | ||
var endNonSelfFreeingCount = Type.getNonSelfFreeingConstructedCount(); | ||
// any new self-freeing commits should have been freed | ||
assert.equal(startSelfFreeingCount, endSelfFreeingCount); | ||
// no new non-self-freeing commits should have been constructed | ||
assert.equal(startNonSelfFreeingCount, endNonSelfFreeingCount); | ||
}); | ||
} | ||
|
||
module.exports = leakTest; |