PVMG => do { my $a = $!; $a = "Bang!"; $a },
);
-plan(tests => 16 + 4 *12 + 2 * scalar keys %types);
+plan(tests => 20 + 4 * 12 + 2 * scalar keys %types);
#############################################################################
# verify that pointer sizes in array slots are sensible:
#############################################################################
# assert hash and hash key size
+# Note, undef puts PL_sv_undef on perl's stack. Assigning to a hash or array
+# value is always copying, so { a => undef } has a value which is a fresh
+# (allocated) SVt_NULL. Nowever, total_size(undef) isn't a copy, so total_size()
+# sees PL_sv_undef, which is a singleton, interpreter wide, so isn't counted as
+# part of the size. So we need to use an unassigned scalar to get the correct
+# size for a SVt_NULL:
+my $undef;
+
my $hash = {};
$hash->{a} = 1;
is (total_size($hash),
- total_size( { a => undef } ) + total_size(1) - total_size(undef),
+ total_size( { a => undef } ) + total_size(1) - total_size($undef),
'assert hash and hash key size');
#############################################################################
$array = [ 0..$size, undef, undef ]; pop @$array;
$array_size = total_size($array);
- my $scalar_size = total_size(1) * (1+$size) + total_size(undef) * 1 + $ptr_size
+ my $scalar_size = total_size(1) * (1+$size) + total_size($undef) * 1 + $ptr_size
+ $ptr_size * ($size + 2) + total_size([]);
is ($scalar_size, $array_size, "computed right size if full array");
"Type $type, total_size() recurses to the referent");
}
}
+
+{
+ my $sub_size = total_size(\&cmp_array_ro);
+ cmp_ok($sub_size, '>=', 5120, 'subroutine is at least 5K');
+ cmp_ok($sub_size, '<=', 51200, 'subroutine is no more than 50K')
+ or diag 'Is total_size() dragging in the entire symbol table?';
+ cmp_ok(total_size(\%::), '>=', 10240, 'symbol table is at least 100K');
+}
+
+cmp_ok(total_size(\%Exporter::), '>', total_size(\%Exporter::Heavy::));