17_misc_meth.t revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# Check miscellaneous tied-array interface methods
# EXTEND, CLEAR, DELETE, EXISTS
#
my $file = "tf$$.txt";
print "1..35\n";
my $N = 1;
print "ok $N\n"; $N++;
print $o ? "ok $N\n" : "not ok $N\n";
$N++;
# (3-8) EXTEND
$o->EXTEND(3);
$o->EXTEND(4);
$o->EXTEND(3);
# (9-10) CLEAR
@a = ();
# (11-20) EXISTS
if ($] >= 5.006) {
eval << 'TESTS';
$N++;
$a[0] = "I like pie.";
$N++;
$N++;
$a[2] = "GIVE ME PIE";
$N++;
# exists $a[1] is not defined by this module under these circumstances
$N++;
$N++;
$N++;
$N++;
$N++;
$N++;
} else { # perl 5.005 doesn't have exists $array[1]
for (11..20) {
print "ok $_ \# skipped (no exists for arrays)\n";
$N++;
}
}
my $del;
# (21-35) DELETE
if ($] >= 5.006) {
eval << 'TESTS';
# 20020317 Through 0.20, the 'delete' function returned the wrong values.
# 20020317 Through 0.20, we had a bug where deleting an element past the
# end of the array would actually extend the array to that length.
} else { # perl 5.005 doesn't have delete $array[1]
for (21..35) {
print "ok $_ \# skipped (no delete for arrays)\n";
$N++;
}
}
use POSIX 'SEEK_SET';
sub check_contents {
my $x = shift;
my $a;
{ local $/; $a = <FH> }
print "ok $N\n";
} else {
}
$N++;
$N++;
}
sub expect {
if (@_ == 1) {
print $_[0] ? "ok $N\n" : "not ok $N\n";
} elsif (@_ == 2) {
my ($a, $x) = @_;
}
else {
}
} else {
}
$N++;
}
sub ctrlfix {
for (@_) {
s/\n/\\n/g;
s/\r/\\r/g;
}
}
END {
undef $o;
untie @a;
}