@ -12,86 +12,92 @@ function makeAssert(message) {
// child_process
{
const assert = makeAssert ( 'isR efed() not working on process_wrap' ) ;
const assert = makeAssert ( 'unr efed() not working on process_wrap' ) ;
const spawn = require ( 'child_process' ) . spawn ;
const cmd = common . isWindows ? 'rundll32' : 'ls' ;
const cp = spawn ( cmd ) ;
assert ( Object . getPrototypeOf ( cp . _ handle ) . hasOwnProperty ( 'isR efed' ) , true ) ;
assert ( cp . _ handle . isR efed( ) , tru e) ;
assert ( Object . getPrototypeOf ( cp . _ handle ) . hasOwnProperty ( 'unr efed' ) , true ) ;
assert ( cp . _ handle . unr efed( ) , fals e) ;
cp . unref ( ) ;
assert ( cp . _ handle . isR efed( ) , fals e) ;
assert ( cp . _ handle . unr efed( ) , tru e) ;
cp . ref ( ) ;
assert ( cp . _ handle . isRefed ( ) , true ) ;
cp . unref ( ) ;
assert ( cp . _ handle . unrefed ( ) , false ) ;
cp . _ handle . close ( ) ;
assert ( cp . _ handle . unrefed ( ) , false ) ;
}
// dgram
{
const assert = makeAssert ( 'isR efed() not working on udp_wrap' ) ;
const assert = makeAssert ( 'unr efed() not working on udp_wrap' ) ;
const dgram = require ( 'dgram' ) ;
const sock4 = dgram . createSocket ( 'udp4' ) ;
assert ( Object . getPrototypeOf ( sock4 . _ handle ) . hasOwnProperty ( 'isR efed' ) , true ) ;
assert ( sock4 . _ handle . isR efed( ) , tru e) ;
assert ( Object . getPrototypeOf ( sock4 . _ handle ) . hasOwnProperty ( 'unr efed' ) , true ) ;
assert ( sock4 . _ handle . unr efed( ) , fals e) ;
sock4 . unref ( ) ;
assert ( sock4 . _ handle . isR efed( ) , fals e) ;
assert ( sock4 . _ handle . unr efed( ) , tru e) ;
sock4 . ref ( ) ;
assert ( sock4 . _ handle . isRefed ( ) , true ) ;
sock4 . unref ( ) ;
assert ( sock4 . _ handle . unrefed ( ) , false ) ;
sock4 . _ handle . close ( ) ;
assert ( sock4 . _ handle . unrefed ( ) , false ) ;
const sock6 = dgram . createSocket ( 'udp6' ) ;
assert ( Object . getPrototypeOf ( sock6 . _ handle ) . hasOwnProperty ( 'isR efed' ) , true ) ;
assert ( sock6 . _ handle . isR efed( ) , tru e) ;
assert ( Object . getPrototypeOf ( sock6 . _ handle ) . hasOwnProperty ( 'unr efed' ) , true ) ;
assert ( sock6 . _ handle . unr efed( ) , fals e) ;
sock6 . unref ( ) ;
assert ( sock6 . _ handle . isR efed( ) , fals e) ;
assert ( sock6 . _ handle . unr efed( ) , tru e) ;
sock6 . ref ( ) ;
assert ( sock6 . _ handle . isRefed ( ) , true ) ;
sock6 . unref ( ) ;
assert ( sock6 . _ handle . unrefed ( ) , false ) ;
sock6 . _ handle . close ( ) ;
assert ( sock6 . _ handle . unrefed ( ) , false ) ;
}
// pipe
{
const assert = makeAssert ( 'isR efed() not working on pipe_wrap' ) ;
const assert = makeAssert ( 'unr efed() not working on pipe_wrap' ) ;
const Pipe = process . binding ( 'pipe_wrap' ) . Pipe ;
const handle = new Pipe ( ) ;
assert ( Object . getPrototypeOf ( handle ) . hasOwnProperty ( 'isR efed' ) , true ) ;
assert ( handle . isR efed( ) , tru e) ;
assert ( Object . getPrototypeOf ( handle ) . hasOwnProperty ( 'unr efed' ) , true ) ;
assert ( handle . unr efed( ) , fals e) ;
handle . unref ( ) ;
assert ( handle . isR efed( ) , fals e) ;
assert ( handle . unr efed( ) , tru e) ;
handle . ref ( ) ;
assert ( handle . isRefed ( ) , true ) ;
handle . unref ( ) ;
assert ( handle . unrefed ( ) , false ) ;
handle . close ( ) ;
assert ( handle . unrefed ( ) , false ) ;
}
// tcp
{
const assert = makeAssert ( 'isR efed() not working on tcp_wrap' ) ;
const assert = makeAssert ( 'unr efed() not working on tcp_wrap' ) ;
const net = require ( 'net' ) ;
const server = net . createServer ( ( ) => { } ) . listen ( common . PORT ) ;
assert ( Object . getPrototypeOf ( server . _ handle ) . hasOwnProperty ( 'isR efed' ) , true ) ;
assert ( server . _ handle . isR efed( ) , tru e) ;
assert ( Object . getPrototypeOf ( server . _ handle ) . hasOwnProperty ( 'unr efed' ) , true ) ;
assert ( server . _ handle . unr efed( ) , fals e) ;
assert ( server . _ unref , false ) ;
server . unref ( ) ;
assert ( server . _ handle . isR efed( ) , fals e) ;
assert ( server . _ handle . unr efed( ) , tru e) ;
assert ( server . _ unref , true ) ;
server . ref ( ) ;
assert ( server . _ handle . isR efed( ) , tru e) ;
assert ( server . _ handle . unr efed( ) , fals e) ;
assert ( server . _ unref , false ) ;
server . unref ( ) ;
server . _ handle . close ( ) ;
assert ( server . _ handle . unrefed ( ) , false ) ;
}
// timers
{
const assert = makeAssert ( 'isR efed() not working on timer_wrap' ) ;
const assert = makeAssert ( 'unr efed() not working on timer_wrap' ) ;
const timer = setTimeout ( ( ) => { } , 500 ) ;
timer . unref ( ) ;
assert ( Object . getPrototypeOf ( timer . _ handle ) . hasOwnProperty ( 'isR efed' ) , true ) ;
assert ( timer . _ handle . isR efed( ) , fals e) ;
assert ( Object . getPrototypeOf ( timer . _ handle ) . hasOwnProperty ( 'unr efed' ) , true ) ;
assert ( timer . _ handle . unr efed( ) , tru e) ;
timer . ref ( ) ;
assert ( timer . _ handle . isRefed ( ) , true ) ;
timer . unref ( ) ;
assert ( timer . _ handle . unrefed ( ) , false ) ;
timer . close ( ) ;
assert ( timer . _ handle . unrefed ( ) , false ) ;
}