Deprecate shellwords.pl with a warning
[p5sagit/p5-mst-13.2.git] / lib / autodie / t / hints.t
index a097dab..b508fee 100755 (executable)
@@ -13,7 +13,18 @@ use Test::More 'no_plan';
 use constant NO_SUCH_FILE  => "this_file_had_better_not_exist";
 use constant NO_SUCH_FILE2 => "this_file_had_better_not_exist_xyzzy";
 
-use constant PERL510 => ( $] >= 5.010 );
+use constant PERL510  => ( $] >= 5.0100 );
+use constant PERL5101 => ( $] >= 5.0101 );
+use constant PERL5102 => ( $] >= 5.0102 );
+
+# File::Copy states that all subroutines return '0' on failure.
+# However both Windows and VMS may return other false values
+# (notably empty-string) on failure.  This constant indicates
+# whether we should skip some tests because the return values
+# from File::Copy may not be what's in the documentation.
+
+use constant WEIRDO_FILE_COPY =>
+    ( ! PERL5102 and ( $^O eq "MSWin32" or $^O eq "VMS" ));
 
 use Hints_test qw(
     fail_on_empty fail_on_false fail_on_undef
@@ -22,22 +33,30 @@ use Hints_test qw(
 use autodie qw(fail_on_empty fail_on_false fail_on_undef);
 
 diag("Sub::Identify ", exists( $INC{'Sub/Identify.pm'} ) ? "is" : "is not",
-     " loaded");
+     " loaded") if (! $ENV{PERL_CORE});
 
 my $hints = "autodie::hints";
 
 # Basic hinting tests
 
 is( $hints->sub_fullname(\&copy), 'File::Copy::copy' , "Id: copy" );
-is( $hints->sub_fullname(\&cp),   'File::Copy::copy' , "Id: cp"   );
+is(
+    $hints->sub_fullname(\&cp),
+    PERL5101 ? 'File::Copy::cp' : 'File::Copy::copy' , "Id: cp"
+);
 
 is( $hints->sub_fullname(\&move), 'File::Copy::move' , "Id: move" );
-is( $hints->sub_fullname(\&mv),   'File::Copy::move' , "Id: mv"   );
+is( $hints->sub_fullname(\&mv),
+    PERL5101 ? 'File::Copy::mv' : 'File::Copy::move' , "Id: mv"
+);
 
 if (PERL510) {
     ok( $hints->get_hints_for(\&copy)->{scalar}->(0) ,
         "copy() hints should fail on 0 for scalars."
     );
+    ok( $hints->get_hints_for(\&copy)->{list}->(0) ,
+        "copy() hints should fail on 0 for lists."
+    );
 }
 
 # Scalar context test
@@ -51,6 +70,17 @@ eval {
 isnt("$@", "", "Copying in scalar context should throw an error.");
 isa_ok($@, "autodie::exception");
 
+is($@->function, "File::Copy::copy", "Function should be original name");
+
+SKIP: {
+    skip("File::Copy is weird on Win32/VMS before 5.10.1", 1)
+        if WEIRDO_FILE_COPY;
+
+    is($@->return, 0, "File::Copy returns zero on failure");
+}
+
+is($@->context, "scalar", "File::Copy called in scalar context");
+
 # List context test.
 
 eval {
@@ -62,6 +92,16 @@ eval {
 isnt("$@", "", "Copying in list context should throw an error.");
 isa_ok($@, "autodie::exception");
 
+is($@->function, "File::Copy::copy", "Function should be original name");
+
+SKIP: {
+    skip("File::Copy is weird on Win32/VMS before 5.10.1", 1)
+        if WEIRDO_FILE_COPY;
+
+    is_deeply($@->return, [0], "File::Copy returns zero on failure");
+}
+is($@->context, "list", "File::Copy called in list context");
+
 # Tests on loaded funcs.
 
 my %tests = (