1use Test2::V0 -no_srand => 1;
2BEGIN { skip_all 'Test requires a threading Perl' unless eval q{ use threads; 1 } }
3use FFI::CheckLib;
4use FFI::Platypus;
5use Config;
6
7my $ffi = FFI::Platypus->new(lib => find_lib(lib => 'test', symbol => 'f0', libpath => 't/ffi' ));
8
9sub f0
10{
11  $ffi->function(f0 => ['uint8'] => 'uint8')->call(@_);
12}
13
14sub otherthread
15{
16  my $val = f0(22);
17  undef $ffi;
18  $val;
19}
20
21ok 1;
22
23is(threads->create(\&otherthread)->join(), 22, 'works in a thread');
24
25is f0(24), 24, 'works in main thread';
26
27done_testing;
28