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/data_scalar.t | |
download | File-Slurp-tarball-9d4173f2716c2f9a2d26f8f9ab0f47b351b87de7.tar.gz |
File-Slurp-9999.19HEADFile-Slurp-9999.19master
Diffstat (limited to 't/data_scalar.t')
-rw-r--r-- | t/data_scalar.t | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/t/data_scalar.t b/t/data_scalar.t new file mode 100644 index 0000000..eb24337 --- /dev/null +++ b/t/data_scalar.t @@ -0,0 +1,62 @@ +#!/usr/local/bin/perl -w + +use strict ; +use File::Slurp ; + +use Carp ; +use POSIX qw( :fcntl_h ) ; +use Test::More tests => 1 ; + +# in case SEEK_SET isn't defined in older perls. it seems to always be 0 + +BEGIN { + + *SEEK_SET = sub { 0 } unless defined \&SEEK_SET ; +} + +eval { require B } ; + +SKIP: { + + skip <<TEXT, 1 if $@ ; +B.pm not found in this Perl. Note this will cause slurping of +the DATA handle to fail. +TEXT + + test_data_scalar_slurp() ; +} + +exit ; + + + +exit ; + +sub test_data_scalar_slurp { + + my $data_seek = tell( \*DATA ); + +# first slurp in the text + + my $slurp_text = read_file( \*DATA ) ; + +# now we need to get the golden data + + seek( \*DATA, $data_seek, SEEK_SET ) || die "seek $!" ; + my $data_text = join( '', <DATA> ) ; + + is( $slurp_text, $data_text, 'scalar slurp of DATA' ) ; +} + +__DATA__ +line one +second line +more lines +still more + +enough lines + +we can't test long handle slurps from DATA since i would have to type +too much stuff + +so we will stop here |