From e1fe604c050e61dfbb92655de3af5e096ec67995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 29 Aug 2017 17:03:24 +0200 Subject: [PATCH] test: fix tests after V8 6.0 GC changes Ref: https://github.com/nodejs/citgm/issues/464 --- test/object.js | 11 +++++++---- test/pointer.js | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/test/object.js b/test/object.js index 137e80f..85ac64d 100644 --- a/test/object.js +++ b/test/object.js @@ -21,7 +21,7 @@ describe('Object', function () { assert.deepEqual(obj, out) }) - it('should retain references to written Objects', function () { + it('should retain references to written Objects', function (done) { var o_gc = false var buf_gc = false var o = { foo: 'bar' } @@ -41,9 +41,12 @@ describe('Object', function () { // now GC `buf` buf = null - gc() - assert(buf_gc, '"buf" has not been garbage collected') - assert(o_gc, '"o" has not been garbage collected') + setImmediate(function () { + gc() + assert(buf_gc, '"buf" has not been garbage collected') + assert(o_gc, '"o" has not been garbage collected') + done() + }); }) it('should throw an Error when reading an Object from the NULL pointer', function () { diff --git a/test/pointer.js b/test/pointer.js index af6124f..3aa1300 100644 --- a/test/pointer.js +++ b/test/pointer.js @@ -20,7 +20,7 @@ describe('pointer', function () { assert.strictEqual(ref.address(out), ref.address(test)) }) - it('should retain references to a written pointer in a Buffer', function () { + it('should retain references to a written pointer in a Buffer', function (done) { var child_gc = false var parent_gc = false var child = new Buffer('a pointer holding some data...') @@ -40,9 +40,12 @@ describe('pointer', function () { // now GC `parent` parent = null - gc() - assert(parent_gc, '"parent" has not been garbage collected') - assert(child_gc, '"child" has not been garbage collected') + setImmediate(function () { + gc() + assert(parent_gc, '"parent" has not been garbage collected') + assert(child_gc, '"child" has not been garbage collected') + done() + }); }) it('should throw an Error when reading from the NULL pointer', function () {