This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test tweak from Craig Berry.
[perl5.git] / lib / Tie / File / t / 12_longfetch_rs.t
1 #!/usr/bin/perl
2 #
3 # Make sure we can fetch a record in the middle of the file
4 # before we've ever looked at any records before it
5 #
6 # (tests _fill_offsets_to() )
7 #
8
9 my $file = "tf$$.txt";
10 my $data = "rec0blahrec1blahrec2blah";
11
12 print "1..5\n";
13
14 my $N = 1;
15 use Tie::File;
16 print "ok $N\n"; $N++;
17
18 open F, "> $file" or die $!;
19 binmode F;
20 print F $data;
21 close F;
22
23
24 my $o = tie @a, 'Tie::File', $file, recsep => 'blah';
25 print $o ? "ok $N\n" : "not ok $N\n";
26 $N++;
27
28 my $n;
29
30 # 3-5
31 for (2, 1, 0) {
32   print $a[$_] eq "rec${_}blah" ? "ok $N\n" : "not ok $N # rec=$a[$_] ?\n";
33   $N++;
34 }
35
36 END {
37   undef $o;
38   untie @a;
39   1 while unlink $file;
40 }
41