diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2011-06-07 08:06:16 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2011-06-07 08:06:16 +0000 |
commit | 9d4173f2716c2f9a2d26f8f9ab0f47b351b87de7 (patch) | |
tree | 98ae3fb82096d8bb96686512ada27fa72126b09a /t/chomp.t | |
download | File-Slurp-tarball-master.tar.gz |
File-Slurp-9999.19HEADFile-Slurp-9999.19master
Diffstat (limited to 't/chomp.t')
-rw-r--r-- | t/chomp.t | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/t/chomp.t b/t/chomp.t new file mode 100644 index 0000000..e14319b --- /dev/null +++ b/t/chomp.t @@ -0,0 +1,53 @@ + +use strict ; +use warnings ; + +use lib qw(t) ; + +use File::Slurp qw( read_file write_file ) ; +use Test::More ; + +use TestDriver ; + +my $file = 'edit_file_data' ; + +my $existing_data = <<PRE ; +line 1 +line 2 +more +foo +bar +junk here and foo +last line +PRE + +my $tests = [ + { + name => 'read_file - chomp', + sub => \&read_file, + args => [ + $file, + { + 'chomp' => 1, + array_ref => 1 + }, + ], + pretest => sub { + my( $test ) = @_ ; + write_file( $file, $existing_data ) ; + }, + posttest => sub { + my( $test ) = @_ ; + $test->{ok} = eq_array( + $test->{result}, + [$existing_data =~ /^(.+)\n/gm] + ) ; + }, + }, +] ; + +test_driver( $tests ) ; + +unlink $file ; + +exit ; |