use ExtUtils::testlib;
+use threads;
+
BEGIN {
+ eval {
+ require threads::shared;
+ import threads::shared;
+ };
+ if ($@ || ! $threads::shared::threads_shared) {
+ print("1..0 # Skip: threads::shared not available\n");
+ exit(0);
+ }
+
$| = 1;
print("1..31\n"); ### Number of tests that will be run ###
};
-use threads;
-use threads::shared;
print("ok 1 - Loaded\n");
### Start of Testing ###
ok($th->join());
}
{
- # there is a little chance this test case will falsly fail
- # since it tests rand
+ # There is a miniscule chance this test case may falsely fail
+ # since it tests using rand()
my %rand : shared;
rand(10);
threads->create( sub { $rand{int(rand(10000000000))}++ } ) foreach 1..25;
$_->join foreach threads->list;
-# use Data::Dumper qw(Dumper);
-# print Dumper(\%rand);
- #$val = rand();
- ok((keys %rand == 25), "Check that rand works after a new thread");
+ ok((keys %rand >= 23), "Check that rand() is randomized in new threads");
}
# bugid #24165
-run_perl(prog =>
- 'use threads; sub a{threads->create(shift)} $t = a sub{}; $t->tid; $t->join; $t->tid');
+run_perl(prog => 'use threads 1.58;' .
+ 'sub a{threads->create(shift)} $t = a sub{};' .
+ '$t->tid; $t->join; $t->tid',
+ nolib => ($ENV{PERL_CORE}) ? 0 : 1,
+ switches => ($ENV{PERL_CORE}) ? [] : [ '-Mblib' ]);
is($?, 0, 'coredump in global destruction');
# test CLONE_SKIP() functionality