From: Uri Guttman Date: Tue, 3 May 2011 08:03:48 +0000 (-0400) Subject: added tests for edit_file and edit_file_lines X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d0834228f271f9b01a5842ce3b5e71ee7079b882;p=urisagit%2FFile-Slurp.git added tests for edit_file and edit_file_lines --- diff --git a/t/error.t b/t/error.t index 770b252..a241ee5 100644 --- a/t/error.t +++ b/t/error.t @@ -9,7 +9,7 @@ BEGIN { } use TestDriver ; -use File::Slurp qw( :all prepend_file ) ; +use File::Slurp qw( :all prepend_file edit_file ) ; my $is_win32 = $^O =~ /cygwin|win32/i ; @@ -87,7 +87,36 @@ my $tests = [ error => qr/write_file/, posttest => sub { unlink $file_name, "$file_name.$$" }, }, - + { + name => 'edit_file read error', + sub => \&edit_file, + args => [ sub{}, $file_name ], + error => qr/read_file/, + }, + { + name => 'edit_file write error', + sub => \&edit_file, + pretest => sub { write_file( $file_name, '' ) }, + args => [ sub{}, $file_name ], + override => 'syswrite', + error => qr/write_file/, + posttest => sub { unlink $file_name, "$file_name.$$" }, + }, + { + name => 'edit_file_lines read error', + sub => \&edit_file_lines, + args => [ sub{}, $file_name ], + error => qr/read_file/, + }, + { + name => 'edit_file_lines write error', + sub => \&edit_file_lines, + pretest => sub { write_file( $file_name, '' ) }, + args => [ sub{}, $file_name ], + override => 'syswrite', + error => qr/write_file/, + posttest => sub { unlink $file_name, "$file_name.$$" }, + }, ] ; test_driver( $tests ) ;