Ensure threads terminate properly
[p5sagit/Class-Accessor-Grouped.git] / t / accessors_xs.t
index b373a94..63bce81 100644 (file)
@@ -58,18 +58,32 @@ for my $tname (qw/accessors.t accessors_ro.t accessors_wo.t/) {
     local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /subroutine .+ redefined/i };
 
     do($tfn);
+
+    666;
   };
 
   if ($has_threads) {
-    threads->create(sub {
-      threads->create(sub {
-        $todo->() for (1,2) }
-      )->join;
-      $todo->() for (1,2);
-    })->join for (1,2)
+    for (1,2) {
+      is (
+        threads->create(sub {
+          is (
+            threads->create(sub {
+              $todo->();
+            })->join,
+            666,
+            'Innner thread joined ok',
+          );
+          777;
+        })->join,
+        777,
+        'Outer thread joined ok',
+      );
+
+      is ($todo->(), 666, "Unthreaded run ok") for (1,2);
+    }
   }
   else {
-    $todo->() for (1, 2);
+    is ($todo->(), 666, "Unthreaded run ok") for (1,2);
   }
 }