Clone-AsUTF8Bytes
view release on metacpan or search on metacpan
AsUTF8Bytes.xs view on Meta::CPAN
else if (SvROK (ref))
{
TRACEME(("clone = 0x%x(%d)\n", clone, SvREFCNT(clone)));
SvREFCNT_dec(SvRV(clone));
SvRV(clone) = sv_clone (SvRV(ref), hseen, depth); /* Clone the referent */
if (sv_isobject (ref))
{
sv_bless (clone, SvSTASH (SvRV (ref)));
}
if (SvWEAKREF(ref)) {
sv_rvweaken(clone);
}
}
TRACEME(("clone = 0x%x(%d)\n", clone, SvREFCNT(clone)));
return clone;
}
MODULE = Clone::AsUTF8Bytes PACKAGE = Clone::AsUTF8Bytes
PROTOTYPES: ENABLE
t/06refcnt.t view on Meta::CPAN
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
my $HAS_WEAKEN;
BEGIN {
$| = 1;
my $plan = 20;
eval 'use Scalar::Util qw( weaken isweak );';
if ($@) {
$HAS_WEAKEN = 0;
$plan = 15;
}
else {
$HAS_WEAKEN = 1;
}
print "1..$plan\n";
}
t/06refcnt.t view on Meta::CPAN
bless $a, 'Test::Hash';
bless $b, 'Test::Hash';
}
# test for cloning weak reference
if ( $HAS_WEAKEN ) {
{
my $a = new Test::Hash();
my $b = { r => $a };
$a->{r} = $b;
weaken($b->{'r'});
my $c = clone_as_utf8_bytes($a);
}
# another weak reference problem, this one causes a segfault in 0.24
{
my $a = new Test::Hash();
{
my $b = [ $a, $a ];
$a->{r} = $b;
weaken($b->[0]);
weaken($b->[1]);
}
my $c = clone_as_utf8_bytes($a);
# check that references point to the same thing
print "not " unless $c->{'r'}[0] == $c->{'r'}[1];
printf "ok %d\n", $::test++;
}
}
t/07magic.t view on Meta::CPAN
use strict;
use Clone::AsUTF8Bytes;
use Test::More tests => 3;
SKIP: {
eval "use Data::Dumper";
skip "Data::Dumper not installed", 1 if $@;
SKIP: {
eval "use Scalar::Util qw( weaken )";
skip "Scalar::Util not installed", 1 if $@;
my $x = { a => "worked\n" };
my $y = $x;
weaken($y);
my $z = Clone::AsUTF8Bytes::clone_as_utf8_bytes($x);
ok( Dumper($x) eq Dumper($z), "Cloned weak reference");
}
## RT 21859: Clone segfault (isolated example)
SKIP: {
my $string = "HDDR-WD-250JS";
eval {
use utf8;
utf8::upgrade($string);
( run in 0.347 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )