Upgrade to Tie::File 0.19.
[p5sagit/p5-mst-13.2.git] / lib / Tie / File / t / 02_fetchsize.t
1 #!/usr/bin/perl
2
3 my $file = "tf$$.txt";
4 $: = Tie::File::_default_recsep();
5 my $data = "rec1$:rec2$:rec3$:";
6
7 print "1..6\n";
8
9 my $N = 1;
10 use Tie::File;
11 print "ok $N\n"; $N++;
12
13 open F, "> $file" or die $!;
14 binmode F;
15 print F $data;
16 close F;
17
18
19 my $o = tie @a, 'Tie::File', $file;
20 print $o ? "ok $N\n" : "not ok $N\n";
21 $N++;
22
23 $: = $o->{recsep};
24
25 my $n;
26
27 # 3  test array element count
28 $n = @a;
29 print $n == 3 ? "ok $N\n" : "not ok $N # n=$n\n";
30 $N++;
31
32 # 4 same thing again   
33 $n = @a;
34 print $n == 3 ? "ok $N\n" : "not ok $N # n=$n\n";
35 $N++;
36
37 # 5  test $#a notation
38 $n = $#a;
39 print $n == 2 ? "ok $N\n" : "not ok $N # n=$n\n";
40 $N++;
41
42 # 6  test looping over array elements
43 my $q;
44 for (@a) { $q .= $_ }
45 print $q eq $data ? "ok $N\n" : "not ok $N # n=$n\n";
46 $N++;
47
48 END {
49   undef $o;
50   untie @a;
51   1 while unlink $file;
52 }
53