3 # There are few filetest operators that are portable enough to test.
4 # See pod/perlport.pod for details.
21 # make sure TEST is r-x
22 eval { chmod 0555, 'TEST' or die "chmod 0555, 'TEST' failed: $!" };
23 chomp ($bad_chmod = $@);
25 $oldeuid = $>; # root can read and write anything
26 eval '$> = 1'; # so switch uid (may not be implemented)
28 print "# oldeuid = $oldeuid, euid = $>\n";
31 if (!$Config{d_seteuid}) {
34 elsif ($Config{config_args} =~/Dmksymlinks/) {
35 skip('we cannot chmod symlinks');
45 # Scripts are not -x everywhere so cannot test that.
47 eval '$> = $oldeuid'; # switch uid back (may not be implemented)
49 # this would fail for the euid 1
50 # (unless we have unpacked the source code as uid 1...)
53 # this would fail for the euid 1
54 # (unless we have unpacked the source code as uid 1...)
56 if ($Config{d_seteuid}) {
63 ok( -x 'op' ); # Hohum. Are directories -x everywhere?
65 is( "@{[grep -r, qw(foo io noo op zoo)]}", "io op" );
67 # Test stackability of filetest operators
69 ok( defined( -f -d 'TEST' ) && ! -f -d _ );
70 ok( !defined( -e 'zoo' ) );
71 ok( !defined( -e -d 'zoo' ) );
72 ok( !defined( -f -e 'zoo' ) );
75 ok( defined(-d -e 'TEST') );
76 ok( defined(-e -d 'TEST') );
79 ok( (-s -f 'TEST' > 1), "-s returns real size" );
80 ok( -f -s 'TEST' == 1 );
82 # now with an empty file
83 my $tempfile = tempfile();
84 open my $fh, ">", $tempfile;
87 is( -s $tempfile, 0 );
88 is( -f -s $tempfile, 0 );
89 is( -s -f $tempfile, 0 );
92 # test that _ is a bareword after filetest operators
96 sub _ { "this is not a file name" }
103 use overload -X => sub { $over = \@_; "-$_[1]"; };
106 my $o = bless [], "OverFtest";
107 for my $op (split //, "rwxoRWXOezsfdlpSbctugkTMBAC") {
108 ok( my $rv = eval "-$op \$o", "overloaded -$op succeeds" );
109 is( $over->[0], $o, "correct object for overloaded -$op" );
110 is( $over->[1], $op, "correct op for overloaded -$op" );
111 is( $rv, "-$op", "correct return value for overloaded -$op");