This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
-t should only return TRUE for file handles connected to a TTY
[perl5.git] / t / op / filetest_t.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     require './test.pl';
7 }
8
9 use strict;
10
11 plan 2;
12
13 my($dev_tty, $dev_null) = qw(/dev/tty /dev/null);
14   ($dev_tty, $dev_null) = qw(con      nul      ) if $^O =~ /^(MSWin32|os2)$/;
15   ($dev_tty, $dev_null) = qw(TT:      _NLA0:   ) if $^O eq "VMS";
16
17 SKIP: {
18     open(my $tty, "<", $dev_tty)
19         or skip("Can't open terminal '$dev_tty': $!");
20     ok(-t $tty);
21 }
22 SKIP: {
23     open(my $null, "<", $dev_null)
24         or skip("Can't open null device '$dev_null': $!");
25     ok(!-t $null);
26 }