12 my $o = tie @a, 'Tie::File', $file,
13 recsep => $RECSEP, autochomp => 0, autodefer => 0;
14 print $o ? "ok $N\n" : "not ok $N\n";
20 check_contents("rec0");
24 check_contents("rec0", "rec1");
26 check_contents("rec0", "rec1", "rec2");
28 # 9-14 same-length alterations
30 check_contents("new0", "rec1", "rec2");
32 check_contents("new0", "new1", "rec2");
34 check_contents("new0", "new1", "new2");
36 # 15-24 lengthening alterations
38 check_contents("long0", "new1", "new2");
40 check_contents("long0", "long1", "new2");
42 check_contents("long0", "long1", "long2");
44 check_contents("long0", "longer1", "long2");
46 check_contents("longer0", "longer1", "long2");
48 # 25-34 shortening alterations, including truncation
50 check_contents("short0", "longer1", "long2");
52 check_contents("short0", "short1", "long2");
54 check_contents("short0", "short1", "short2");
56 check_contents("short0", "sh1", "short2");
58 check_contents("sh0", "sh1", "short2");
62 check_contents("sh0", "sh1", "short2", "", "rec4");
64 check_contents("sh0", "sh1", "short2", "rec3", "rec4");
66 # (35-37) zero out file
70 # (38-40) insert into the middle of an empty file
72 check_contents("", "", "", "rec3");
75 # (41-46) 20020326 You thought there would be a bug in STORE where if
76 # a cached record was false, STORE wouldn't see it at all. Yup, there is,
77 # and adding the appropriate defined() test fixes the problem.
78 undef $o; untie @a; 1 while unlink $file;
80 $o = tie @a, 'Tie::File', $file,
81 recsep => $RECSEP, autochomp => 0, autodefer => 0;
82 print $o ? "ok $N\n" : "not ok $N\n";
85 my $z = $a[1]; # caches "0"
87 check_contents("", "", "oops");
89 check_contents("", "bah", "oops");
95 my $x = join $RECSEP, @c, '';
99 { local $/; $a = <FH> }
101 $a = "" unless defined $a;
105 my $msg = "# expected <$x>, got <$a>";
107 print "not ok $N $msg\n";
114 unless ($a[$_] eq "$c[$_]$RECSEP") {
115 $msg = "expected $c[$_]$RECSEP, got $a[$_]";
120 print $good ? "ok $N\n" : "not ok $N # fetch $msg\n";
136 1 while unlink $file;