$YAML::XS::LoadBlessed
= 1;
for
( 1 .. 3 ) {
foreach
my
$case
(
sub
{
"foo"
},
sub
{
bless
{
foo
=>
"bar"
},
"Class"
},
sub
{ [ 1 .. 3 ] },
sub
{
my
$x
=
"foo"
; \
$x
; },
sub
{
my
$y
= 42;
my
$x
= \
$y
; \
$x
},
sub
{
my
$h
= {}; [
$h
,
$h
] },
) {
my
$obj
=
$case
->();
my
$yaml
= Dump(
$obj
);
ok(
$yaml
,
"dumped"
);
my
$loaded
= Load(
$yaml
);
is(
ref
(
$loaded
),
ref
(
$obj
),
"loaded $loaded from $obj"
);
is_deeply(
$loaded
,
$obj
,
"eq deeply"
);
if
(
ref
$obj
) {
weaken(
$obj
);
weaken(
$loaded
);
is(
$obj
,
undef
,
"dumped object not leaked"
);
is(
$loaded
,
undef
,
"loaded object not leaked"
);
}
}
}