20_cache_full.t revision 1
1N/A# Tests for various caching errors 1N/Aprint "ok $N\n"; $N++;
1N/A# Limit cache size to 30 bytes 1N/A# -- that's enough space for 3 records, but not 4, on both \n and \r\n systems 1N/Aprint $o ?
"ok $N\n" :
"not ok $N\n";
1N/A# (3-5) Let's see if data was properly expired from the cache 1N/Amy @z = @a;
# force cache to contain all ten records 1N/A# It should now contain only the *last* three records, 7, 8, and 9 1N/A if ($a eq $x) { print "ok $N\n" } 1N/A else { print "not ok $N # cache keys were <$a>; expected <$x>\n" } 1N/A# Here we redo *all* the splice tests, with populate() 1N/A# calls before each one, to make sure that splice() does not botch the cache. 1N/A# (6-25) splicing at the beginning 1N/Asplice(@a, 0, 0, 'r7', 'rec8'); # insert more than one 1N/Asplice(@a, 0, 2, 'rec7', 'record8', 'rec9'); # insert more than delete 1N/Asplice(@a, 0, 3, 'record9', 'rec10'); # delete more than insert 1N/A# (26-45) splicing in the middle 1N/Asplice(@a, 1, 0, 'r7', 'rec8'); # insert more than one 1N/Asplice(@a, 1, 2, 'rec7', 'record8', 'rec9'); # insert more than delete 1N/Asplice(@a, 1, 3, 'record9', 'rec10'); # delete more than insert 1N/A# (46-65) splicing at the end 1N/Asplice(@a, 3, 0, 'r7', 'rec8'); # insert more than one 1N/Asplice(@a, 3, 2, 'rec7', 'record8', 'rec9'); # insert more than delete 1N/Asplice(@a, 3, 3, 'record9', 'rec10'); # delete more than insert 1N/A# (66-85) splicing with negative subscript 1N/Asplice(@a, -1, 0, 'r7', 'rec8'); # insert more than one 1N/Asplice(@a, -1, 2, 'rec7', 'record8', 'rec9'); # insert more than delete 1N/Asplice(@a, -3, 3, 'record9', 'rec10'); # delete more than insert 1N/A# (86-87) scrub it all out 1N/A# (88-89) put some back in 1N/A# (90-91) what if we remove too many records? 1N/A# (92-95) In the past, splicing past the end was not correctly detected 1N/A# (96-99) Also we did not emulate splice's freaky behavior when inserting 1N/A# past the end of the array (1.14) 1N/A# (100-105) Test default arguments 1N/A# (106-111) One last set of tests. I don't know what state the cache 1N/A# is in now. But if I read any three records, those three records are 1N/A# what should be in the cache, and nothing else. 1N/A@a = "record0" .. "record9"; 1N/Acheck(); # In 0.18 #107 fails here--STORE was not flushing the cache when 1N/A # replacing an old cached record with a longer one 1N/Afor (5, 6, 1) { my $z = $a[$_] } 1N/A if ($a eq $x) { print "ok $N\n" } 1N/A else { print "not ok $N # LRU was <$a>; expected <$x>\n" } 1N/A if ($a eq $x) { print "ok $N\n" } 1N/A else { print "not ok $N # cache keys were <$a>; expected <$x>\n" } 1N/A : "not ok $N # $b bytes cached, should be <= $MAX\n";