#!./perl
if
(-d
"lib"
&& -f
"TEST"
) {
if
(
$Config
{
'extensions'
} !~ /\bDB_File\b/ ) {
plan
skip_all
=>
'DB_File was not built'
;
}
}
plan
skip_all
=>
'Threads are disabled'
unless
$Config
{usethreads};
plan
skip_all
=>
'Thread test needs Perl 5.8.7 or greater'
unless
$] >= 5.008007;
plan
tests
=> 7;
use_ok(
'threads'
);
my
$TEMPDIR
= tempdir(
CLEANUP
=> 1 );
chdir
$TEMPDIR
;
my
%h
;
unlink
<threads*>;
my
$db
=
tie
%h
,
'DB_File'
,
'threads'
, O_RDWR|O_CREAT, 0640;
isa_ok(
$db
,
'DB_File'
);
for
(1 .. 2) {
ok(threads->create(
sub
{
$SIG
{
'__WARN__'
} =
sub
{ fail(
shift
) };
1;
}),
"Thread $_ created"
);
}
for
(threads->list) {
is(
$_
->
join
, 1,
"A thread exited successfully"
);
}
pass(
"Tied object survived exiting threads"
);
undef
$db
;
untie
%h
;
unlink
<threads*>;