Commit | Line | Data |
635c7876 |
1 | #!/usr/local/bin/perl -w |
2 | |
3 | use strict ; |
99709852 |
4 | use File::Slurp ; |
635c7876 |
5 | |
6 | use Carp ; |
7 | use POSIX qw( :fcntl_h ) ; |
99709852 |
8 | use Test::More tests => 1 ; |
635c7876 |
9 | |
10 | # in case SEEK_SET isn't defined in older perls. it seems to always be 0 |
11 | |
12 | BEGIN { |
13 | |
99709852 |
14 | *SEEK_SET = sub { 0 } unless defined \&SEEK_SET ; |
635c7876 |
15 | } |
16 | |
17 | eval { require B } ; |
18 | |
19 | SKIP: { |
20 | |
21 | skip <<TEXT, 1 if $@ ; |
22 | B.pm not found in this Perl. Note this will cause slurping of |
23 | the DATA handle to fail. |
24 | TEXT |
25 | |
26 | test_data_scalar_slurp() ; |
27 | } |
28 | |
29 | exit ; |
30 | |
31 | |
32 | |
33 | exit ; |
34 | |
35 | sub test_data_scalar_slurp { |
36 | |
37 | my $data_seek = tell( \*DATA ); |
38 | |
39 | # first slurp in the text |
40 | |
41 | my $slurp_text = read_file( \*DATA ) ; |
42 | |
43 | # now we need to get the golden data |
44 | |
45 | seek( \*DATA, $data_seek, SEEK_SET ) || die "seek $!" ; |
46 | my $data_text = join( '', <DATA> ) ; |
47 | |
48 | is( $slurp_text, $data_text, 'scalar slurp of DATA' ) ; |
49 | } |
50 | |
51 | __DATA__ |
52 | line one |
53 | second line |
54 | more lines |
55 | still more |
56 | |
57 | enough lines |
58 | |
59 | we can't test long handle slurps from DATA since i would have to type |
60 | too much stuff |
61 | |
62 | so we will stop here |