mirror of
https://github.com/nodejs/node.git
synced 2025-05-08 18:53:34 +00:00

PR-URL: https://github.com/nodejs/node/pull/16567 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
58 lines
1.1 KiB
JavaScript
58 lines
1.1 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const fs = require('fs');
|
|
const tty = require('tty');
|
|
|
|
common.expectsError(
|
|
() => new tty.WriteStream(-1),
|
|
{
|
|
code: 'ERR_INVALID_FD',
|
|
type: RangeError,
|
|
message: '"fd" must be a positive integer: -1'
|
|
}
|
|
);
|
|
|
|
{
|
|
const message = common.isWindows ?
|
|
'bad file descriptor: EBADF [uv_tty_init]' :
|
|
'invalid argument: EINVAL [uv_tty_init]';
|
|
|
|
common.expectsError(
|
|
() => {
|
|
let fd = 2;
|
|
// Get first known bad file descriptor.
|
|
try {
|
|
while (fs.fstatSync(++fd));
|
|
} catch (e) { }
|
|
new tty.WriteStream(fd);
|
|
}, {
|
|
code: 'ERR_SYSTEM_ERROR',
|
|
type: Error,
|
|
message
|
|
}
|
|
);
|
|
|
|
common.expectsError(
|
|
() => {
|
|
let fd = 2;
|
|
// Get first known bad file descriptor.
|
|
try {
|
|
while (fs.fstatSync(++fd));
|
|
} catch (e) { }
|
|
new tty.ReadStream(fd);
|
|
}, {
|
|
code: 'ERR_SYSTEM_ERROR',
|
|
type: Error,
|
|
message
|
|
});
|
|
}
|
|
|
|
common.expectsError(
|
|
() => new tty.ReadStream(-1),
|
|
{
|
|
code: 'ERR_INVALID_FD',
|
|
type: RangeError,
|
|
message: '"fd" must be a positive integer: -1'
|
|
}
|
|
);
|