1#!perl 2 3use strict; 4use warnings; 5 6BEGIN { 7 use Config; 8 if ($Config{extensions} !~ /\bEncode\b/) { 9 print "1..0 # Skip: no Encode\n"; 10 exit 0; 11 } 12 unless ($Config{useithreads}) { 13 print "1..0 # Skip: no threads\n"; 14 exit 0; 15 } 16} 17 18use threads; 19 20use Test::More tests => 3 + 1; 21 22binmode *STDOUT, ':encoding(UTF-8)'; 23 24SKIP: { 25 local $@; 26 my $ret = eval { 27 my $thread = threads->create(sub { pass 'in thread'; return 1 }); 28 skip 'test thread could not be spawned' => 3 unless $thread; 29 $thread->join; 30 }; 31 is $@, '', 'thread did not croak'; 32 is $ret, 1, 'thread returned the right value'; 33} 34 35pass 'passes at least one test'; 36