265de939abe9f204a3c9c1c04d660e72e30713c7
[p5sagit/p5-mst-13.2.git] / lib / Tie / File / t / 03_longfetch.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 $: = Tie::File::_default_recsep();
11 my $data = "rec0$:rec1$:rec2$:";
12
13 print "1..5\n";
14
15 my $N = 1;
16 use Tie::File;
17 print "ok $N\n"; $N++;
18
19 open F, "> $file" or die $!;
20 binmode F;
21 print F $data;
22 close F;
23
24
25 my $o = tie @a, 'Tie::File', $file;
26 print $o ? "ok $N\n" : "not ok $N\n";
27 $N++;
28
29 $: = $o->{recsep};
30
31 my $n;
32
33 # 3-5
34 for (2, 1, 0) {
35   print $a[$_] eq "rec$_$:" ? "ok $N\n" : "not ok $N # rec=$a[$_] ?\n";
36   $N++;
37 }
38
39 END {
40   undef $o;
41   untie @a;
42   1 while unlink $file;
43 }
44