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