From: Vincent Pit Date: Sat, 20 Sep 2008 21:34:29 +0000 (+0200) Subject: Test same signature across threads X-Git-Tag: v0.20~8 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FVariable-Magic.git;a=commitdiff_plain;h=b539f7ed264d210a08d390f94aab06f7d0aafb10 Test same signature across threads --- 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'); +