| 1 | #!perl |
| 2 | |
| 3 | use strict; |
| 4 | use warnings; |
| 5 | |
| 6 | BEGIN { |
| 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 | |
| 18 | use threads; |
| 19 | |
| 20 | use Test::More tests => 3 + 1; |
| 21 | |
| 22 | binmode *STDOUT, ':encoding(UTF-8)'; |
| 23 | |
| 24 | SKIP: { |
| 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 | |
| 35 | pass 'passes at least one test'; |