From b906bfce1a9b14562b891b352994b681f217983f Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Sun, 30 Aug 2026 13:59:54 +0800 Subject: [PATCH] test(generator): restore locale after float formatting test --- phpunit/src/OperatorTest.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/phpunit/src/OperatorTest.php b/phpunit/src/OperatorTest.php index 09c2bdff..92e4823a 100644 --- a/phpunit/src/OperatorTest.php +++ b/phpunit/src/OperatorTest.php @@ -148,8 +148,13 @@ class OperatorTest extends \BaseTest public function testFloatLiteralEmissionIsLocaleIndependent(): void { - $previousLocale = setlocale(LC_ALL, 'de_DE.UTF-8', 'da_DK.UTF-8', 'en_DK.utf8'); + $previousLocale = setlocale(LC_NUMERIC, 0); try { + $selectedLocale = setlocale(LC_NUMERIC, 'de_DE.UTF-8', 'da_DK.UTF-8', 'en_DK.utf8'); + if ($selectedLocale === false || localeconv()['decimal_point'] !== ',') { + $this->markTestSkipped('No comma-decimal locale is available'); + } + global $translator; $compiler = \TypePhp\CompilerTest::create(TYPEPHP_ROOT_PATH); $translator = $compiler; @@ -158,7 +163,7 @@ class OperatorTest extends \BaseTest $this->assertStringNotContainsString(',', $result); } finally { if ($previousLocale !== false) { - setlocale(LC_ALL, $previousLocale); + setlocale(LC_NUMERIC, $previousLocale); } } }