This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Sync regcomp warn with reality.
[perl5.git] / t / op / filetest.t
CommitLineData
42e55ab1
JH
1#!./perl
2
3# There are few filetest operators that are portable enough to test.
4# See pod/perlport.pod for details.
5
6BEGIN {
7 chdir 't' if -d 't';
eb57363f 8 unshift @INC, '../lib' if -d '../lib';
42e55ab1
JH
9}
10
eb57363f 11use Config;
42e55ab1
JH
12print "1..10\n";
13
14print "not " unless -d 'op';
15print "ok 1\n";
16
17print "not " unless -f 'TEST';
18print "ok 2\n";
19
20print "not " if -f 'op';
21print "ok 3\n";
22
23print "not " if -d 'TEST';
24print "ok 4\n";
25
26print "not " unless -r 'TEST';
27print "ok 5\n";
28
22c35a8c
GS
29# make sure TEST is r-x
30eval { chmod 0555, 'TEST' };
846f25a3
GW
31$bad_chmod = $@;
32
33$oldeuid = $>; # root can read and write anything
34eval '$> = 1'; # so switch uid (may not be implemented)
35
36print "# oldeuid = $oldeuid, euid = $>\n";
37
38if ($bad_chmod) {
39 print "#[$@]\nok 6 #skipped\n";
22c35a8c
GS
40}
41else {
846f25a3
GW
42 print "not " if -w 'TEST';
43 print "ok 6\n";
22c35a8c 44}
42e55ab1 45
846f25a3 46# Scripts are not -x everywhere so cannot test that.
42e55ab1
JH
47
48print "not " unless -r 'op';
49print "ok 7\n";
50
846f25a3
GW
51eval '$> = $oldeuid'; # switch uid back (may not be implemented)
52
53# this would fail for the euid 1
54# (unless we have unpacked the source code as uid 1...)
3eeba6fb
CB
55if ($Config{d_seteuid}) {
56 print "not " unless -w 'op';
57 print "ok 8\n";
58} else {
59 print "ok 8 #skipped, no seteuid\n";
60}
42e55ab1
JH
61
62print "not " unless -x 'op'; # Hohum. Are directories -x everywhere?
63print "ok 9\n";
64
65print "not " unless "@{[grep -r, qw(foo io noo op zoo)]}" eq "io op";
66print "ok 10\n";