Skip to content

Commit e1fe604

Browse files
committed
test: fix tests after V8 6.0 GC changes
Ref: nodejs/citgm#464
1 parent 0e26fcf commit e1fe604

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

test/object.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('Object', function () {
2121
assert.deepEqual(obj, out)
2222
})
2323

24-
it('should retain references to written Objects', function () {
24+
it('should retain references to written Objects', function (done) {
2525
var o_gc = false
2626
var buf_gc = false
2727
var o = { foo: 'bar' }
@@ -41,9 +41,12 @@ describe('Object', function () {
4141

4242
// now GC `buf`
4343
buf = null
44-
gc()
45-
assert(buf_gc, '"buf" has not been garbage collected')
46-
assert(o_gc, '"o" has not been garbage collected')
44+
setImmediate(function () {
45+
gc()
46+
assert(buf_gc, '"buf" has not been garbage collected')
47+
assert(o_gc, '"o" has not been garbage collected')
48+
done()
49+
});
4750
})
4851

4952
it('should throw an Error when reading an Object from the NULL pointer', function () {

test/pointer.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('pointer', function () {
2020
assert.strictEqual(ref.address(out), ref.address(test))
2121
})
2222

23-
it('should retain references to a written pointer in a Buffer', function () {
23+
it('should retain references to a written pointer in a Buffer', function (done) {
2424
var child_gc = false
2525
var parent_gc = false
2626
var child = new Buffer('a pointer holding some data...')
@@ -40,9 +40,12 @@ describe('pointer', function () {
4040

4141
// now GC `parent`
4242
parent = null
43-
gc()
44-
assert(parent_gc, '"parent" has not been garbage collected')
45-
assert(child_gc, '"child" has not been garbage collected')
43+
setImmediate(function () {
44+
gc()
45+
assert(parent_gc, '"parent" has not been garbage collected')
46+
assert(child_gc, '"child" has not been garbage collected')
47+
done()
48+
});
4649
})
4750

4851
it('should throw an Error when reading from the NULL pointer', function () {

0 commit comments

Comments
 (0)