19_cache.t revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# Tests for various caching errors
#
$|=1;
my $file = "tf$$.txt";
print "1..55\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) Through 0.18, this 'splice' call would corrupt the cache.
my @z = @a; # force cache to contain all ten records
$N++;
# Here we redo *all* the splice tests, with populate()
# calls before each one, to make sure that splice() does not botch the cache.
# (4-14) splicing at the beginning
check();
check();
check();
check();
check();
check();
check();
check();
check();
check();
check();
# (15-24) splicing in the middle
check();
check();
check();
check();
check();
check();
check();
check();
check();
check();
# (25-34) splicing at the end
check();
check();
check();
check();
check();
check();
check();
check();
check();
check();
# (35-44) splicing with negative subscript
check();
check();
check();
check();
check();
check();
check();
check();
check();
check();
# (45) scrub it all out
splice(@a, 0, 3);
check();
# (46) put some back in
check();
# (47) what if we remove too many records?
splice(@a, 0, 17);
check();
# (48-49) In the past, splicing past the end was not correctly detected
# (1.14)
splice(@a, 89, 3);
check();
splice(@a, @a, 3);
check();
# (50-51) Also we did not emulate splice's freaky behavior when inserting
# past the end of the array (1.14)
check();
check();
# (52-54) Test default arguments
check();
splice @a, 4;
check();
splice @a;
check();
# (55) This was broken on 20030507 when you moved the cache management
# stuff out of _oadjust back into _splice without also putting it back
# into _store.
@a = (0..11);
check();
sub init_file {
my $data = shift;
binmode F;
print F $data;
close F;
}
sub check {
$N++;
}
sub ctrlfix {
for (@_) {
s/\n/\\n/g;
s/\r/\\r/g;
}
}
sub repopulate {
my @z = @a; # refill the cache with correct data
}
END {
undef $o;
untie @a;
}