11 my $o = tie @a, 'Tie::File', $file;
12 print $o ? "ok $N\n" : "not ok $N\n";
17 check_contents("rec0");
21 check_contents("rec0", "rec1");
23 check_contents("rec0", "rec1", "rec2");
25 # 9-14 same-length alterations
27 check_contents("new0", "rec1", "rec2");
29 check_contents("new0", "new1", "rec2");
31 check_contents("new0", "new1", "new2");
33 # 15-24 lengthening alterations
35 check_contents("long0", "new1", "new2");
37 check_contents("long0", "long1", "new2");
39 check_contents("long0", "long1", "long2");
41 check_contents("long0", "longer1", "long2");
43 check_contents("longer0", "longer1", "long2");
45 # 25-34 shortening alterations, including truncation
47 check_contents("short0", "longer1", "long2");
49 check_contents("short0", "short1", "long2");
51 check_contents("short0", "short1", "short2");
53 check_contents("short0", "sh1", "short2");
55 check_contents("sh0", "sh1", "short2");
59 check_contents("sh0", "sh1", "short2", "", "rec4");
61 check_contents("sh0", "sh1", "short2", "rec3", "rec4");
64 # try inserting a record into the middle of an empty file
69 my $x = join $/, @c, '';
72 # my $open = open FH, "< $file";
74 { local $/; $a = <FH> }
75 $a = "" unless defined $a;
79 s{$/}{\\n}g for $a, $x;
80 print "not ok $N\n# expected <$x>, got <$a>\n";
88 unless ($a[$_] eq "$c[$_]$/") {
89 $msg = "expected $c[$_]$/, got $a[$_]";
94 print $good ? "ok $N\n" : "not ok $N # $msg\n";
101 1 while unlink $file;