]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - t/40-threads.t
This is 0.64
[perl/modules/Variable-Magic.git] / t / 40-threads.t
index 9b2d2fa2c95fd59bfbf691ab9413cea011703006..85d51934635b395a1801f4378fe6d2b54f8eaa68 100644 (file)
@@ -33,12 +33,15 @@ sub try {
     set     => sub {
      my $op = $_[-1];
 
+     my $assign_op    = ("$]" < 5.037_003) ? 'sassign': 'padsv_store';
+     my $assign_op_cl = ("$]" < 5.037_003) ? 'B::BINOP': 'B::UNOP';
+
      if ($op_info eq 'object') {
       is_deeply { class => ref($op),   name => $op->name },
-                { class => 'B::BINOP', name => 'sassign' },
+                { class => $assign_op_cl, name => $assign_op },
                 "op object in thread $tid is correct";
      } else {
-      is $op, 'sassign', "op name in thread $tid is correct";
+      is $op, $assign_op, "op name in thread $tid is correct";
      }
 
      return 0;
@@ -102,7 +105,8 @@ sub try {
    is $c, 1,  "get in thread $tid after dispell doesn't trigger magic";
   }
  }
- return; # Ugly if not here
+
+ return 1;
 }
 
 for my $dispell (1, 0) {
@@ -111,11 +115,16 @@ for my $dispell (1, 0) {
   $destroyed = 0;
  }
 
+ my $completed = 0;
+
  my @threads = map spawn(\&try, $dispell, $_), ('name') x 2, ('object') x 2;
- $_->join for @threads;
+ for my $thr (@threads) {
+  my $res = $thr->join;
+  $completed += $res if defined $res;
+ }
 
  {
   lock $destroyed;
-  is $destroyed, (1 - $dispell) * 4, 'destructors';
+  is $destroyed, (1 - $dispell) * $completed, 'destructors';
  }
 }