summaryrefslogtreecommitdiff
path: root/t/data_scalar.t
blob: eb24337103a7ab8de3f927059942804ab03c47a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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