X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F40-threads.t;h=c31986019f76ece988fcf32de577cd4fcda8a3a2;hb=b539f7ed264d210a08d390f94aab06f7d0aafb10;hp=2215c592aaa3a72e739e4f1f11d08d3ac573ca4c;hpb=23438375d18947cd5f9a8a055063e10af478c318;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/40-threads.t b/t/40-threads.t index 2215c59..c319860 100644 --- a/t/40-threads.t +++ b/t/40-threads.t @@ -9,7 +9,7 @@ BEGIN { if (!$Config{useithreads}) { require Test::More; Test::More->import; - plan(skip_all => 'This Perl wasn\'t built to support threads'); + plan(skip_all => 'This perl wasn\'t built to support threads'); } } @@ -21,20 +21,23 @@ use Test::More; use Variable::Magic qw/wizard cast dispell getdata VMG_THREADSAFE/; if (VMG_THREADSAFE) { - plan tests => 2 * 16 + 1; + plan tests => 2 * (2 * 16 + 1); } else { plan skip_all => 'This Variable::Magic isn\'t thread safe'; } my $destroyed : shared = 0; +my $sig = undef; + sub try { my $tid = threads->tid(); my $c = 0; my $wiz = eval { wizard get => sub { ++$c }, data => sub { $_[1] + $tid }, - free => sub { ++$destroyed }; + free => sub { ++$destroyed }, + sig => $sig; }; is($@, '', "wizard in thread $tid doesn't croak"); isnt($wiz, undef, "wizard in thread $tid is defined"); @@ -68,3 +71,13 @@ $t[0]->join; $t[1]->join; is($destroyed, 0, 'destructors didn\'t fired'); + +$destroyed = 0; +$sig = Variable::Magic::gensig(); + +@t = map { threads->create(\&try) } 1 .. 2; +$t[0]->join; +$t[1]->join; + +is($destroyed, 0, 'destructors didn\'t fired'); +