1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!./perl
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require './test.pl';
}
use strict;
plan 7;
my($dev_tty, $dev_null) = qw(/dev/tty /dev/null);
($dev_tty, $dev_null) = qw(con nul ) if $^O =~ /^(MSWin32|os2)$/;
($dev_tty, $dev_null) = qw(TT: _NLA0: ) if $^O eq "VMS";
SKIP: {
open(my $tty, "<", $dev_tty)
or skip("Can't open terminal '$dev_tty': $!");
if ($^O eq 'VMS') {
# TT might be a mailbox or other non-terminal device
my $tt_dev = VMS::Filespec::vmspath('TT');
skip("'$tt_dev' is probably not a terminal") if $tt_dev !~ m/^_(tt|ft|rt)/i;
}
ok(-t $tty, "'$dev_tty' is a TTY");
ok(-t -e $tty, "'$dev_tty' is a TTY (with -t -e)");
-e 'mehyparchonarcheion'; # clear last stat buffer
ok(-e -t $tty, "'$dev_tty' is a TTY (with -e -t)");
-e 'mehyparchonarcheion';
ok(-e -t -t $tty, "'$dev_tty' is a TTY (with -e -t -t)");
}
SKIP: {
open(my $null, "<", $dev_null)
or skip("Can't open null device '$dev_null': $!");
ok(!-t $null, "'$dev_null' is not a TTY");
ok(!-t -e $null, "'$dev_null' is not a TTY (with -t -e)");
ok(!-e -t $null, "'$dev_null' is not a TTY (with -e -t)");
}
|