Upgrade to Math-Complex-1.47
[p5sagit/p5-mst-13.2.git] / lib / File / CheckTree.t
index 58cca3a..b8a5652 100755 (executable)
@@ -7,10 +7,20 @@ BEGIN {
 
 use Test;
 
-BEGIN { plan tests => 6 }
+BEGIN { plan tests => 8 }
 
 use strict;
 
+BEGIN {
+# Cwd::cwd does an implicit "require Win32", but
+# the ../lib directory in @INC will no longer work once
+# we chdir() out of the "t" directory.
+    if ($^O eq 'MSWin32') {
+       require Win32;
+       Win32->import();
+    }
+}
+
 use File::CheckTree;
 use File::Spec;          # used to get absolute paths
 
@@ -18,7 +28,7 @@ use File::Spec;          # used to get absolute paths
 # Will move up one level to make it easier to generate
 # reliable pathnames for testing File::CheckTree
 
-chdir('..') or die "cannot change to parent of t/ directory: $!";
+chdir(File::Spec->updir) or die "cannot change to parent of t/ directory: $!";
 
 
 #### TEST 1 -- No warnings ####
@@ -39,10 +49,11 @@ chdir('..') or die "cannot change to parent of t/ directory: $!";
             # indented comment, followed blank line (w/o whitespace):
 
             README -f
-            $path_to_README -e || warn
+            '$path_to_README' -e || warn
         };
     };
 
+    print STDERR $_ for @warnings;
     if ( !$@ && !@warnings && defined($num_warnings) && $num_warnings == 0 ) {
         ok(1);
     }
@@ -116,7 +127,7 @@ chdir('..') or die "cannot change to parent of t/ directory: $!";
 # cd directive followed by relative paths, followed by full paths
 {
     my ($num_warnings, @warnings, $path_to_libFile, $path_to_dist);
-    $path_to_libFile = File::Spec->rel2abs('lib/File');
+    $path_to_libFile = File::Spec->rel2abs(File::Spec->catdir('lib','File'));
     $path_to_dist    = File::Spec->rel2abs(File::Spec->curdir);
 
     local $SIG{__WARN__} = sub { push @warnings, "@_" };
@@ -124,13 +135,13 @@ chdir('..') or die "cannot change to parent of t/ directory: $!";
     eval {
         $num_warnings = validate qq{
             lib                -d || die
-            $path_to_libFile   cd
+            '$path_to_libFile' cd
             Spec               -e
             Spec               -f
-            $path_to_dist      cd
+            '$path_to_dist'    cd
             README             -ef
             INSTALL            -d || warn
-            $path_to_libFile   -d || die
+            '$path_to_libFile' -d || die
         };
     };
 
@@ -192,3 +203,39 @@ chdir('..') or die "cannot change to parent of t/ directory: $!";
         ok(0);
     }
 }
+
+#### TEST 7 -- Quoted file names ####
+{
+    my $num_warnings;
+    eval {
+        $num_warnings = validate q{
+            "a file with whitespace" !-ef
+            'a file with whitespace' !-ef
+        };
+    };
+
+    if ( !$@ ) {
+       # No errors mean we compile correctly
+        ok(1);
+    } else {
+        ok(0);
+       print STDERR $@;
+    };
+}
+
+#### TEST 8 -- Malformed query ####
+{
+    my $num_warnings;
+    eval {
+        $num_warnings = validate q{
+            a file with whitespace !-ef
+        };
+    };
+
+    if ( $@ =~ /syntax error/) {
+       # We got a syntax error for a malformed file query
+        ok(1);
+    } else {
+        ok(0);
+    };
+}