Make C<undef ~~ 0> and C<undef ~~ ""> not match (like in 5.10.0)
[p5sagit/p5-mst-13.2.git] / t / op / filetest.t
old mode 100755 (executable)
new mode 100644 (file)
index 0fec3c1..c46bdc1
@@ -10,7 +10,7 @@ BEGIN {
 }
 
 use Config;
-plan(tests => 28 + 27*10);
+plan(tests => 28 + 27*14);
 
 ok( -d 'op' );
 ok( -f 'TEST' );
@@ -100,10 +100,11 @@ my $over;
 {
     package OverFtest;
 
-    use overload -X => sub { 
-        $over = [overload::StrVal($_[0]), $_[1]];
-        "-$_[1]"; 
-    };
+    use overload 
+        -X => sub { 
+            $over = [overload::StrVal($_[0]), $_[1]];
+            "-$_[1]"; 
+        };
 }
 {
     package OverString;
@@ -122,7 +123,7 @@ my $over;
 {
     package OverNeither;
 
-    # Need fallback. Previous veraions of perl required 'fallback' to do
+    # Need fallback. Previous versions of perl required 'fallback' to do
     # -X operations on an object with no "" overload.
     use overload 
         '+' => sub { 1 },
@@ -136,6 +137,15 @@ my $both = bless [], "OverBoth";
 my $neither = bless [], "OverNeither";
 my $nstr = overload::StrVal($neither);
 
+open my $gv, "<", "TEST";
+bless $gv, "OverString";
+open my $io, "<", "TEST";
+$io = *{$io}{IO};
+bless $io, "OverString";
+
+my $fcntl_not_available;
+eval { require Fcntl } or $fcntl_not_available = 1;
+
 for my $op (split //, "rwxoRWXOezsfdlpSbctugkTMBAC") {
     $over = [];
     ok( my $rv = eval "-$op \$ft",  "overloaded -$op succeeds" )
@@ -144,12 +154,37 @@ for my $op (split //, "rwxoRWXOezsfdlpSbctugkTMBAC") {
     is( $over->[1], $op,            "correct op for overloaded -$op" );
     is( $rv,        "-$op",         "correct return value for overloaded -$op");
 
+    my ($exp, $is) = (1, "is");
+    if (
+       !$fcntl_not_available and (
+        $op eq "u" and not eval { Fcntl::S_ISUID() } or
+        $op eq "g" and not eval { Fcntl::S_ISGID() } or
+        $op eq "k" and not eval { Fcntl::S_ISVTX() }
+       )
+    ) {
+        ($exp, $is) = (0, "not");
+    }
+
     $over = 0;
     $rv = eval "-$op \$str";
     ok( !$@,                        "-$op succeeds with string overloading" )
         or diag( $@ );
     is( $rv, eval "-$op 'TEST'",    "correct -$op on string overload" );
-    is( $over,      1,              "string overload called for -$op" );
+    is( $over,      $exp,           "string overload $is called for -$op" );
+
+    ($exp, $is) = $op eq "l" ? (1, "is") : (0, "not");
+
+    $over = 0;
+    eval "-$op \$gv";
+    is( $over,      $exp,   "string overload $is called for -$op on GLOB" );
+
+    # IO refs always get string overload called. This might be a bug.
+    $op eq "t" || $op eq "T" || $op eq "B"
+        and ($exp, $is) = (1, "is");
+
+    $over = 0;
+    eval "-$op \$io";
+    is( $over,      $exp,   "string overload $is called for -$op on IO");
 
     $rv = eval "-$op \$both";
     is( $rv,        "-$op",         "correct -$op on string/-X overload" );
@@ -158,6 +193,7 @@ for my $op (split //, "rwxoRWXOezsfdlpSbctugkTMBAC") {
     ok( !$@,                        "-$op succeeds with random overloading" )
         or diag( $@ );
     is( $rv, eval "-$op \$nstr",    "correct -$op with random overloading" );
-}
 
-is( -r -f $ft,  "-r",               "stacked overloaded -X" );
+    is( eval "-r -$op \$ft", "-r",      "stacked overloaded -$op" );
+    is( eval "-$op -r \$ft", "-$op",    "overloaded stacked -$op" );
+}