Debian Codegraph @

ext/XS-APItest/t/boolean-thr.t

raw
1 #!./perl
2
3 use strict;
4 use warnings;
5
6 use Config ();
7 use if !$Config::Config{usethreads}, 'Test::More',
8 skip_all => "This perl does not support threads";
9
10 use Test::More;
11 use XS::APItest;
12
13 use threads;
14 use threads::shared;
15
16 ok(threads->create( sub { SvIsBOOL($_[0]) }, !!0 )->join,
17 'value in to thread is bool');
18
19 ok(SvIsBOOL(threads->create( sub { return !!0 } )->join),
20 'value out of thread is bool');
21
22 {
23 my $var = !!0;
24 ok(threads->create( sub { SvIsBOOL($var) } )->join,
25 'variable captured by thread is bool');
26 }
27
28 {
29 my $sharedvar :shared = !!0;
30
31 ok(SvIsBOOL($sharedvar),
32 ':shared variable is bool outside');
33
34 ok(threads->create( sub { SvIsBOOL($sharedvar) } )->join,
35 ':shared variable is bool inside thread');
36 }
37
38 is(test_bool_internals(), 0, "Bulk test internal bool related APIs");
39
40 done_testing;