edited all .t tests to not use use_ok to load File::Slurp. they now all
[urisagit/Perl-Docs.git] / t / data_scalar.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
17eval { require B } ;
18
19SKIP: {
20
21 skip <<TEXT, 1 if $@ ;
22B.pm not found in this Perl. Note this will cause slurping of
23the DATA handle to fail.
24TEXT
25
26 test_data_scalar_slurp() ;
27}
28
29exit ;
30
31
32
33exit ;
34
35sub 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__
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