xref: /openbsd-src/gnu/usr.bin/perl/ext/XS-APItest/t/boolean-thr.t (revision f2a19305cfc49ea4d1a5feb55cd6c283c6f1e031)
1#!./perl
2
3use strict;
4use warnings;
5
6use Config ();
7use if !$Config::Config{usethreads}, 'Test::More',
8    skip_all => "This perl does not support threads";
9
10use Test::More;
11use XS::APItest;
12
13use threads;
14use threads::shared;
15
16ok(threads->create( sub { SvIsBOOL($_[0]) }, !!0 )->join,
17    'value in to thread is bool');
18
19ok(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
38is(test_bool_internals(), 0, "Bulk test internal bool related APIs");
39
40done_testing;
41