16_handle.t revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# Basic operation, initializing the object from an already-open handle
# instead of from a filename
my $file = "tf$$.txt";
if ($^O =~ /vms/i) {
print "1..0\n";
exit;
}
print "1..39\n";
my $N = 1;
print "ok $N\n"; $N++;
binmode F;
print $o ? "ok $N\n" : "not ok $N\n";
$N++;
# 3-4 create
$a[0] = 'rec0';
# 5-8 append
$a[1] = 'rec1';
$a[2] = 'rec2';
# 9-14 same-length alterations
$a[0] = 'new0';
$a[1] = 'new1';
$a[2] = 'new2';
# 15-24 lengthening alterations
$a[0] = 'long0';
$a[1] = 'long1';
$a[2] = 'long2';
$a[1] = 'longer1';
$a[0] = 'longer0';
# 25-38 shortening alterations, including truncation
$a[0] = 'short0';
$a[1] = 'short1';
$a[2] = 'short2';
$a[1] = 'sh1';
$a[0] = 'sh0';
# file with holes
$a[4] = 'rec4';
$a[3] = 'rec3';
close F;
undef $o;
untie @a;
# (39) Does it correctly detect a non-seekable handle?
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;
print "ok $N # skipped (pipe call failed: $!)\n";
last;
}
close R;
if ($@) {
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++;
}
use POSIX 'SEEK_SET';
sub check_contents {
my @c = @_;
# my $open = open FH, "< $file";
my $a;
{ local $/; $a = <FH> }
print "ok $N\n";
} else {
}
$N++;
# now check FETCH:
my $good = 1;
my $msg;
for (0.. $#c) {
$good = 0;
}
}
$N++;
}
sub ctrlfix {
for (@_) {
s/\n/\\n/g;
s/\r/\\r/g;
}
}
END {
undef $o;
untie @a;
}