|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 | 3 | require('../common');
|
4 |
| -const { strictEqual } = require('assert'); |
| 4 | +const { strictEqual, throws } = require('assert'); |
5 | 5 | const { guessFileDescriptorType } = require('os');
|
6 | 6 |
|
7 | 7 | strictEqual(guessFileDescriptorType(0), 'TTY', 'stdin reported to not be a tty, but it is');
|
8 | 8 | strictEqual(guessFileDescriptorType(1), 'TTY', 'stdout reported to not be a tty, but it is');
|
9 | 9 | strictEqual(guessFileDescriptorType(2), 'TTY', 'stderr reported to not be a tty, but it is');
|
10 | 10 |
|
11 |
| -strictEqual(guessFileDescriptorType(-1), 'INVALID', '-1 reported to be a tty, but it is not'); |
12 |
| -strictEqual(guessFileDescriptorType(55555), 'UNKNOWN', '55555 reported to be a tty, but it is not'); |
13 |
| -strictEqual(guessFileDescriptorType(2 ** 31), 'INVALID', '2^31 reported to be a tty, but it is not'); |
14 |
| -strictEqual(guessFileDescriptorType(1.1), 'INVALID', '1.1 reported to be a tty, but it is not'); |
15 |
| -strictEqual(guessFileDescriptorType('1'), 'INVALID', '\'1\' reported to be a tty, but it is not'); |
16 |
| -strictEqual(guessFileDescriptorType({}), 'INVALID', '{} reported to be a tty, but it is not'); |
17 |
| -strictEqual(guessFileDescriptorType(() => {}), 'INVALID', '() => {} reported to be a tty, but it is not'); |
| 11 | +strictEqual(guessFileDescriptorType(55555), 'UNKNOWN', '55555 reported to be a handle, but it is not'); |
| 12 | +strictEqual(guessFileDescriptorType(2 ** 31 - 1), 'UNKNOWN', '2^31-1 reported to be a handle, but it is not'); |
| 13 | + |
| 14 | +throws(() => guessFileDescriptorType(-1), /"fd" must be a positive integer/, '-1 reported to be a handle, but it is not'); |
| 15 | +throws(() => guessFileDescriptorType(1.1), /"fd" must be a positive integer/, '1.1 reported to be a handle, but it is not'); |
| 16 | +throws(() => guessFileDescriptorType('1'), /"fd" must be a positive integer/, '\'1\' reported to be a tty, but it is not'); |
| 17 | +throws(() => guessFileDescriptorType({}), /"fd" must be a positive integer/, '{} reported to be a tty, but it is not'); |
| 18 | +throws(() => guessFileDescriptorType(() => {}), /"fd" must be a positive integer/, '() => {} reported to be a tty, but it is not'); |
| 19 | +throws(() => guessFileDescriptorType(2 ** 31), /"fd" must be a positive integer/, '2^31 reported to be a handle, but it is not (because the fd check rolls over the input to negative of it)'); |
0 commit comments