7 use Thread::Cleanup::TestThreads;
9 use Test::More 'no_plan';
16 diag 'This will leak some scalars' unless "$]" >= 5.011_005;
27 my ($num, $depth) = @_;
34 spawn(\&cb, $_, $depth);
36 @tids = map $_->tid, @threads;
44 is $ran{$_}, 1, "thread $_ was run once";
45 is $called{$_}, 1, "thread $_ destructor was called once";
52 my $tid = threads->tid;
62 is $x, $y, "\$x in thread $tid";
65 $_->join for test_threads $num, $depth - 1;
70 Thread::Cleanup::register {
71 my $tid = threads->tid;
82 is $x, $num, "\$x in destructor of thread $tid";
86 $_->join for test_threads $num, $depth;
90 is $x, -1, '$x in the main thread';