]> git.vpit.fr Git - perl/modules/Scope-Upper.git/commitdiff
Port t/79-uid-threads.t to the new threads interface
authorVincent Pit <vince@profvince.com>
Mon, 3 Aug 2015 17:09:01 +0000 (14:09 -0300)
committerVincent Pit <vince@profvince.com>
Mon, 3 Aug 2015 21:30:21 +0000 (18:30 -0300)
For some reason it was still calling threads->create(). This commit also
makes sure that the test is resilient to stray exits.

t/79-uid-threads.t

index 81321c1193a46ca476bdf359d6f261fcd614ec16..817a144973440f8102f5161a2b7ef93d626ef28f 100644 (file)
@@ -37,14 +37,16 @@ sub cb {
 
 my %uids;
 my $threads = 0;
 
 my %uids;
 my $threads = 0;
-for my $thread (map threads->create(\&cb), 1 .. 30) {
- ++$threads;
+for my $thread (map spawn(\&cb), 1 .. 30) {
  my $tid = $thread->tid;
  my $uid = $thread->join;
  my $tid = $thread->tid;
  my $uid = $thread->join;
- ++$uids{$uid};
- ok !validate_uid($uid), "\$here is no longer valid (out of thread $tid)";
+ if (defined $uid) {
+  ++$threads;
+  ++$uids{$uid};
+  ok !validate_uid($uid), "\$here is no longer valid (out of thread $tid)";
+ }
 }
 
 is scalar(keys %uids), $threads, 'all the UIDs were different';
 
 }
 
 is scalar(keys %uids), $threads, 'all the UIDs were different';
 
-done_testing($threads * 5 + 1);
+done_testing;