2018-08-23 14:20:12 +00:00
|
|
|
// Flags: --expose-internals --no-warnings
|
2016-07-19 03:50:27 +00:00
|
|
|
'use strict';
|
|
|
|
|
2022-05-05 13:15:03 +00:00
|
|
|
// See also test/parallel/test-handle-wrap-hasref.js
|
2016-07-19 03:50:27 +00:00
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const strictEqual = require('assert').strictEqual;
|
|
|
|
const ReadStream = require('tty').ReadStream;
|
|
|
|
const tty = new ReadStream(0);
|
2018-08-23 14:20:12 +00:00
|
|
|
const { internalBinding } = require('internal/test/binding');
|
|
|
|
const isTTY = internalBinding('tty_wrap').isTTY;
|
2016-07-19 03:50:27 +00:00
|
|
|
strictEqual(isTTY(0), true, 'tty_wrap: stdin is not a TTY');
|
|
|
|
strictEqual(tty._handle.hasRef(),
|
|
|
|
true, 'tty_wrap: not initially refed');
|
|
|
|
tty.unref();
|
|
|
|
strictEqual(tty._handle.hasRef(),
|
|
|
|
false, 'tty_wrap: unref() ineffective');
|
|
|
|
tty.ref();
|
|
|
|
strictEqual(tty._handle.hasRef(),
|
|
|
|
true, 'tty_wrap: ref() ineffective');
|
|
|
|
tty._handle.close(common.mustCall(() =>
|
2017-07-25 17:37:08 +00:00
|
|
|
strictEqual(tty._handle.hasRef(),
|
|
|
|
false, 'tty_wrap: not unrefed on close')));
|