Skip to content

Commit

Permalink
Reset the original locale after testing the Turkic locale
Browse files Browse the repository at this point in the history
  • Loading branch information
choroba committed Jun 20, 2024
1 parent 7ccc68f commit 1fc290e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/Syntax/Construct.pm
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,12 @@ sub _hook {
eval {
use locale;
require POSIX;
POSIX::setlocale(POSIX::LC_ALL(), 'tr_TR.UTF-8');
lc 'I' ne 'i'
my $orig_locale = POSIX::setlocale(POSIX::LC_CTYPE());
(POSIX::setlocale(POSIX::LC_CTYPE(), 'tr_TR.UTF-8') || "")
eq 'tr_TR.UTF-8' or die;
my $cmp = lc 'I' ne 'i';
POSIX::setlocale(POSIX::LC_CTYPE(), $orig_locale);
$cmp
} or die 'Turkic locale casing not working at '
. _position(1) . "\.\n";
},
Expand Down
9 changes: 7 additions & 2 deletions t/02-constructs.t
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@ my %tests = (
q("\N{ORIYA DIGIT FOUR}" =~ m'\N{ORIYA DIGIT FOUR}'), 1 ],
[ 'turkic-casing',
'use locale; use POSIX "locale_h";' . skippable(
'eval{setlocale(LC_ALL, "tr_TR.UTF-8") eq "tr_TR.UTF-8" or die;'
. ' lc "I" eq "\N{LATIN SMALL LETTER DOTLESS I}"}',
'my $o = setlocale(LC_CTYPE);'
. 'eval {'
. '(setlocale(LC_CTYPE, "tr_TR.UTF-8") || "") eq "tr_TR.UTF-8"'
. 'or die;'
. 'my $r = lc "I" eq "\N{LATIN SMALL LETTER DOTLESS I}";'
. 'setlocale(LC_CTYPE, $o);'
. '$r }',
'": testing locale not supported"',
"", '1'),
1 ],
Expand Down

0 comments on commit 1fc290e

Please sign in to comment.