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 () {