Upgrade to Math-Complex-1.47
[p5sagit/p5-mst-13.2.git] / lib / File / CheckTree.t
index 60f1a42..b8a5652 100755 (executable)
@@ -7,14 +7,19 @@ 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.
-use Win32;
+    if ($^O eq 'MSWin32') {
+       require Win32;
+       Win32->import();
+    }
+}
 
 use File::CheckTree;
 use File::Spec;          # used to get absolute paths
@@ -44,10 +49,11 @@ chdir(File::Spec->updir) 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);
     }
@@ -129,13 +135,13 @@ chdir(File::Spec->updir) 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
         };
     };
 
@@ -197,3 +203,39 @@ chdir(File::Spec->updir) 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);
+    };
+}