Debian Codegraph @

t/threads.t

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