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