# instead of from a filename
my $file = "tf$$.txt";
+$: = Tie::File::_default_recsep();
if ($^O =~ /vms/i) {
print "1..0\n";
use Fcntl 'O_CREAT', 'O_RDWR';
sysopen F, $file, O_CREAT | O_RDWR
or die "Couldn't create temp file $file: $!; aborting";
-binmode(F);
+binmode F;
-my $o = tie @a, 'Tie::File', \*F;
+my $o = tie @a, 'Tie::File', \*F, autochomp => 0, autodefer => 0;
print $o ? "ok $N\n" : "not ok $N\n";
$N++;
$a[0] = 'longer0';
check_contents("longer0", "longer1", "long2");
-# 25-34 shortening alterations, including truncation
+# 25-38 shortening alterations, including truncation
$a[0] = 'short0';
check_contents("short0", "longer1", "long2");
$a[1] = 'short1';
undef $o;
untie @a;
-# Does it correctly detect a non-seekable handle?
-
-{
- if ($^O =~ /^(MSWin32|dos)$/) {
- print "ok $N \# skipped ($^O has broken pipe semantics)\n";
- last;
- }
- my $pipe_succeeded = eval {pipe *R, *W};
- if ($@) {
- chomp $@;
- print "ok $N \# skipped (no pipes: $@)\n";
- last;
- } elsif (! $pipe_succeeded) {
- print "ok $N \# skipped (pipe call failed: $!)\n";
- last;
- }
- close R;
- $o = eval {tie @a, 'Tie::File', \*W};
- if ($@) {
- if ($@ =~ /filehandle does not appear to be seekable/) {
- print "ok $N\n";
- } else {
- chomp $@;
- print "not ok $N \# \$\@ is $@\n";
- }
- } else {
- print "not ok $N \# passing pipe to TIEARRAY didn't abort program\n";
- }
- $N++;
+# (39) Does it correctly detect a non-seekable handle?
+{ if ($^O =~ /^(MSWin32|dos|beos)$/) {
+ print "ok $N # skipped ($^O has broken pipe semantics)\n";
+ last;
+ }
+ if ($] < 5.006) {
+ print "ok $N # skipped - 5.005_03 panics after this test\n";
+ last;
+ }
+ my $pipe_succeeded = eval {pipe *R, *W};
+ if ($@) {
+ chomp $@;
+ print "ok $N # skipped (no pipes: $@)\n";
+ last;
+ } elsif (! $pipe_succeeded) {
+ print "ok $N # skipped (pipe call failed: $!)\n";
+ last;
+ }
+ close R;
+ $o = eval {tie @a, 'Tie::File', \*W};
+ if ($@) {
+ if ($@ =~ /filehandle does not appear to be seekable/) {
+ print "ok $N\n";
+ } else {
+ chomp $@;
+ print "not ok $N \# \$\@ is $@\n";
+ }
+ } else {
+ print "not ok $N \# passing pipe to TIEARRAY didn't abort program\n";
+ }
+ $N++;
}
-# try inserting a record into the middle of an empty file
-
use POSIX 'SEEK_SET';
sub check_contents {
my @c = @_;
- my $x = join $/, @c, '';
+ my $x = join $:, @c, '';
local *FH = $o->{fh};
seek FH, 0, SEEK_SET;
# my $open = open FH, "< $file";
if ($a eq $x) {
print "ok $N\n";
} else {
- s{$/}{\\n}g for $a, $x;
- print "not ok $N\n# expected <$x>, got <$a>\n";
+ ctrlfix(my $msg = "# expected <$x>, got <$a>");
+ print "not ok $N\n$msg\n";
}
$N++;
my $good = 1;
my $msg;
for (0.. $#c) {
- unless ($a[$_] eq "$c[$_]$/") {
- $msg = "expected $c[$_]$/, got $a[$_]";
- $msg =~ s{$/}{\\n}g;
+ unless ($a[$_] eq "$c[$_]$:") {
+ $msg = "expected $c[$_]$:, got $a[$_]";
+ ctrlfix($msg);
$good = 0;
}
}
$N++;
}
+
+sub ctrlfix {
+ for (@_) {
+ s/\n/\\n/g;
+ s/\r/\\r/g;
+ }
+}
+
END {
undef $o;
untie @a;