#
# Check interactions of deferred writing
# with miscellaneous methods like DELETE, EXISTS,
# FETCHSIZE, STORESIZE, CLEAR, EXTEND
#
use POSIX 'SEEK_SET';
my $file = "tf$$.txt";
my $data = "rec0$:rec1$:rec2$:";
my ($o, $n);
print "1..53\n";
my $N = 1;
print "ok $N\n"; $N++;
binmode F;
print F $data;
close F;
print $o ? "ok $N\n" : "not ok $N\n";
$N++;
# (3-6) EXISTS
if ($] >= 5.006) {
eval << 'TESTS';
$o->defer;
$a[4] = "rec4";
$o->discard;
} else {
for (3..6) {
print "ok $_ \# skipped (no exists for arrays)\n";
$N++;
}
}
# (7-10) FETCHSIZE
$o->defer;
expect($#a, 2);
$a[4] = "rec4";
expect($#a, 4);
$o->discard;
# (11-21) STORESIZE
$o->defer;
$#a = 4;
expect($#a, 4);
$o->flush;
expect($#a, 4);
$o->defer;
$a[4] = "rec4";
$#a = 2;
$o->flush;
# (22-28) CLEAR
$o->defer;
$a[9] = "rec9";
@a = ();
$o->flush;
# (29-34) EXTEND
# Actually it's not real clear what these tests are for
# since EXTEND has no defined semantics
$o->defer;
@a = (0..3);
$o->flush;
# (35-53) DELETE
if ($] >= 5.006) {
eval << 'TESTS';
my $del;
$o->defer;
$a[2] = "cookies";
$a[0] = "crackers";
$o->flush;
} else {
for (35..53) {
print "ok $_ \# skipped (no delete for arrays)\n";
$N++;
}
}
################################################################
# my $integrity = $o->_check_integrity($file, $ENV{INTEGRITY});
# print $integrity ? "ok $N\n" : "not ok $N\n";
# $N++;
my $good = 1;
$N++;
}
my $good = 1;
my %b_seen;
$good = 0;
$b_seen{$k} = 1;
$good = 0;
} else {
$b_seen{$k} = 1;
}
}
$good = 0;
}
}
}
my $x = shift;
$N++;
my $a;
{ local $/; $a = <FH> }
print "ok $N\n";
} else {
}
$N++;
}
sub expect {
if (@_ == 1) {
print $_[0] ? "ok $N\n" : "not ok $N\n";
} elsif (@_ == 2) {
my ($a, $x) = @_;
}
else {
}
} else {
}
$N++;
}
sub ctrlfix {
local $_ = shift;
s/\n/\\n/g;
s/\r/\\r/g;
$_;
}
END {
undef $o;
untie @a;
}