From 1c6ce212d37a2a17424675e94afb035a9a446f9f Mon Sep 17 00:00:00 2001 From: James E Keenan Date: Sun, 8 Dec 2013 16:10:01 +0100 Subject: [PATCH] Test previously untested branches in lib/File/Find.pm. --- ext/File-Find/t/find.t | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/ext/File-Find/t/find.t b/ext/File-Find/t/find.t index 03a2145..4b52f1e 100644 --- a/ext/File-Find/t/find.t +++ b/ext/File-Find/t/find.t @@ -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"); +} -- 2.7.4