BEGIN {
if
(
$ENV
{PERL_CORE}) {
chdir
't'
if
-d
't'
;
@INC
=
'../lib'
;
}
}
our
$count
: shared;
package
=>
'Without'
,
package
=>
'WithCloneCoderef'
,
fixup
=>
sub
{
$count
++ },
package
=>
'WithCloneName'
,
fixup
=>
'fixup'
,
package
=>
'WithCloneFQName'
,
fixup
=>
'WithCloneFQName::fixup'
,
;
$count
= 0;
eval
{ Without->new };
ok (!$@,
"Object going out of scope: $@"
);
is(
$count
,0,
"Check # of fixups of Without"
);
foreach
(
qw(WithCloneCoderef WithCloneName WithCloneFQName)
) {
$count
= 0;
eval
{
$_
->new };
ok (!$@,
"Execution ok: $@"
);
is(
$count
,0,
"Check # of fixups of $_"
);
$count
= 0;
eval
{
my
$object
=
$_
->new;
threads->new(
sub
{1} )->
join
foreach
1..5;
};
ok (!$@,
"Execution ok: $@"
);
is(
$count
,5,
"Check # of fixups of $_, with threads"
);
}
sub
new {
bless
[],
shift
}
sub
new {
bless
{},
shift
}
sub
new {
bless
{},
shift
}
sub
fixup {
$count
++ }
sub
new {
bless
{},
shift
}
sub
fixup {
$count
++ }