use strict;
use threads;
use threads::shared;
+use Hash::Util 'lock_keys';
# Note that we can't use Test::More here, as we would need to
# call is() from within the DESTROY() function at global destruction time,
# and parts of Test::* may have already been freed by then
-print "1..10\n";
+print "1..14\n";
my $test : shared = 1;
my ($got, $want, $desc) = @_;
unless ($got eq $want) {
print "# EXPECTED: $want\n";
- print "# GOT: got\n";
+ print "# GOT: $got\n";
print "not ";
}
print "ok $test - $desc\n";
# print $string eq 'foobar' ? '' : 'not ', "ok $test - returning closure\n";
# $test++;
+# Nothing is checking that total keys gets cloned correctly.
+
+my %h = (1,2,3,4);
+is (keys %h, 2, "keys correct in parent");
+
+my $child = threads->new(sub { return scalar keys %h })->join;
+is ($child, 2, "keys correct in child");
+
+lock_keys (%h);
+delete $h{1};
+
+is (keys %h, 1, "keys correct in parent with restricted hash");
+
+$child = threads->new(sub { return scalar keys %h })->join;
+is ($child, 1, "keys correct in child with restricted hash");
+
1;
SvANY(dstr) = new_XPVHV();
SvCUR_set(dstr, SvCUR(sstr));
SvLEN_set(dstr, SvLEN(sstr));
+ HvTOTALKEYS(dstr) = HvTOTALKEYS(sstr);
SvMAGIC_set(dstr, mg_dup(SvMAGIC(sstr), param));
SvSTASH_set(dstr, hv_dup_inc(SvSTASH(sstr), param));
{