clean_context(aTHX_ cxt);
/*
+ * Tied elements seem to need special handling.
+ */
+
+ if (SvTYPE(sv) == SVt_PVLV && SvRMAGICAL(sv) && mg_find(sv, 'p')) {
+ mg_get(sv);
+ }
+
+ /*
* do_store() optimizes for dclone by not freeing its context, should
* we need to allocate one because we're deep cloning from a hook.
*/
use Storable qw(dclone);
-print "1..10\n";
+print "1..12\n";
$a = 'toto';
$b = \$a;
print ref $clone eq ref $empty_string_obj &&
$$clone eq $$empty_string_obj &&
$$clone eq '' ? "ok 10\n" : "not ok 10\n";
+
+
+# Do not fail if Tie::Hash and/or Tie::StdHash is not available
+if (eval { require Tie::Hash; scalar keys %Tie::StdHash:: }) {
+ tie my %tie, "Tie::StdHash" or die $!;
+ $tie{array} = [1,2,3,4];
+ $tie{hash} = {1,2,3,4};
+ my $clone_array = dclone $tie{array};
+ print "not " unless "@$clone_array" eq "@{$tie{array}}";
+ print "ok 11\n";
+ my $clone_hash = dclone $tie{hash};
+ print "not " unless $clone_hash->{1} eq $tie{hash}{1};
+ print "ok 12\n";
+} else {
+ print <<EOF;
+ok 11 # skip No Tie::StdHash available
+ok 12 # skip No Tie::StdHash available
+EOF
+}