Test previously untested branches in lib/File/Find.pm.
authorJames E Keenan <jkeenan@cpan.org>
Sun, 8 Dec 2013 15:10:01 +0000 (16:10 +0100)
committerJames E Keenan <jkeenan@cpan.org>
Mon, 9 Dec 2013 01:59:03 +0000 (02:59 +0100)
ext/File-Find/t/find.t

index 03a2145..4b52f1e 100644 (file)
@@ -24,7 +24,7 @@ BEGIN {
 }
 
 my $symlink_exists = eval { symlink("",""); 1 };
-my $test_count = 98;
+my $test_count = 102;
 $test_count += 127 if $symlink_exists;
 $test_count += 26 if $^O eq 'MSWin32';
 $test_count += 2 if $^O eq 'MSWin32' and $symlink_exists;
@@ -1008,3 +1008,32 @@ if ($^O eq 'MSWin32') {
             or warn "can't unlink /$expected_first_file: $!\n";
     }
 }
+
+{
+    local $@;
+    eval { File::Find::find( 'foobar' ); };
+    like($@, qr/no &wanted subroutine given/,
+        "find() correctly died for lack of &wanted via either coderef or hashref");
+}
+
+{
+    local $@;
+    eval { File::Find::find( { follow => 1 } ); };
+    like($@, qr/no &wanted subroutine given/,
+        "find() correctly died for lack of &wanted via hashref");
+}
+
+{
+    local $@;
+    eval { File::Find::find( { wanted => 1 } ); };
+    like($@, qr/no &wanted subroutine given/,
+        "find() correctly died: lack of coderef as value of 'wanted' element");
+}
+
+{
+    local $@;
+    my $wanted = sub { print "hello world\n"; };
+    eval { File::Find::find( $wanted, ( undef ) ); };
+    like($@, qr/invalid top directory/,
+        "find() correctly died due to undefined top directory");
+}