This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Bump the perl version 5.27.1 -> 5.27.2
[perl5.git] / lib / locale_threads.t
CommitLineData
706055ce
KW
1use strict;
2use warnings;
3
4# This file tests interactions with locale and threads
5
6BEGIN {
7 chdir 't' if -d 't';
8 require './test.pl';
9 set_up_inc('../lib');
10 require './loc_tools.pl';
11 skip_all("No locales") unless locales_enabled();
12 skip_all_without_config('useithreads');
13 $| = 1;
14}
15
16SKIP: { # perl #127708
2c6c88ec 17 my @locales = grep { $_ !~ / ^ C \b | POSIX /x } find_locales('LC_MESSAGES');
706055ce
KW
18 skip("No valid locale to test with", 1) unless @locales;
19
20 # reset the locale environment
21 local @ENV{'LANG', (grep /^LC_/, keys %ENV)};
22 local $ENV{LC_MESSAGES} = $locales[0];
23
24 # We're going to try with all possible error numbers on this platform
25 my $error_count = keys(%!) + 1;
26
27 print fresh_perl("
28 use threads;
29 use strict;
30 use warnings;
31
32 my \$errnum = 1;
33
34 my \@threads = map +threads->create(sub {
35 sleep 0.1;
36
37 for (1..5_000) {
38 \$errnum = (\$errnum + 1) % $error_count;
39 \$! = \$errnum;
40
41 # no-op to trigger stringification
42 next if \"\$!\" eq \"\";
43 }
44 }), (0..1);
45 \$_->join for splice \@threads;",
46 {}
47 );
48
49 pass("Didn't segfault");
50}
51
52done_testing;