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