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