04_splice.t revision 1
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# Check SPLICE function's effect on the file
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# (07_rv_splice.t checks its return value)
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# Each call to 'check_contents' actually performs two tests.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# First, it calls the tied object's own 'check_integrity' method,
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# which makes sure that the contents of the read cache and offset tables
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# accurately reflect the contents of the file.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# Then, it checks the actual contents of the file against the expected
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# contents.
9512fe850e98fdd448c638ca63fdd92a8a510255ahlprint "1..118\n";
9512fe850e98fdd448c638ca63fdd92a8a510255ahlprint "ok $N\n"; $N++; # partial credit just for showing up
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# (3-22) splicing at the beginning
9512fe850e98fdd448c638ca63fdd92a8a510255ahlsplice(@a, 0, 2, 'rec7', 'record8', 'rec9'); # insert more than delete
9512fe850e98fdd448c638ca63fdd92a8a510255ahlsplice(@a, 0, 3, 'record9', 'rec10'); # delete more than insert
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# (23-42) splicing in the middle
9512fe850e98fdd448c638ca63fdd92a8a510255ahlsplice(@a, 1, 2, 'rec7', 'record8', 'rec9'); # insert more than delete
9512fe850e98fdd448c638ca63fdd92a8a510255ahlcheck_contents("rec0$:rec7$:record8$:rec9$:rec1$:rec2$:");
9512fe850e98fdd448c638ca63fdd92a8a510255ahlsplice(@a, 1, 3, 'record9', 'rec10'); # delete more than insert
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# (43-62) splicing at the end
splice @a, 4;
splice @a;
splice @a, -1, 1000;
$N++; $good = 1;
$N++; $good = 1;
my @r = splice @a, 2;
$N++; $good = 1;
splice @a, 0, -3;
splice @a, 1, -3;
splice @a, 7, -3;
splice @a, 0, -3;
splice @a, 1, -3;
splice @a, 7, -3;
my $data = shift;
binmode F;
print F $data;
close F;
undef $o;
untie @a;