Skip to content

[libcxx][test][AIX] address more platform differences in locale tests #94826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 14, 2024

Conversation

daltenty
Copy link
Member

@daltenty daltenty commented Jun 8, 2024

This is a follow on to #92312, where we address some more locale platform differences. These are:

  • for locale fr_FR AIX libc expects U202F as LC_MONETARY thousands_sep
  • for locale zh_CN AIX libc LC_MONETARY has n_sign_posn == 1, indicating the negative_sign should come before the currency_symbol string

@daltenty daltenty requested a review from a team as a code owner June 8, 2024 01:35
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jun 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 8, 2024

@llvm/pr-subscribers-libcxx

Author: David Tenty (daltenty)

Changes

This is a follow on to #92312, where we address some more locale platform differences. These are:

  • for locale fr_FR AIX libc expects U202F as LC_MONETARY thousands_sep
  • for locale zh_CN AIX libc LC_MONETARY has n_sign_posn == 1, indicating the negative_sign should come before the currency_symbol string

Patch is 29.32 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/94826.diff

4 Files Affected:

  • (modified) libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp (+21-16)
  • (modified) libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp (+30-7)
  • (modified) libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp (+21-16)
  • (modified) libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp (+50-11)
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
index 3effa80e7d6f7..1ce64ee218738 100644
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
@@ -11,8 +11,6 @@
 // NetBSD does not support LC_MONETARY at the moment
 // XFAIL: netbsd
 
-// XFAIL: LIBCXX-AIX-FIXME
-
 // REQUIRES: locale.fr_FR.UTF-8
 
 // <locale>
@@ -32,6 +30,13 @@
 #include "platform_support.h" // locale name macros
 #include "test_macros.h"
 
+#ifdef _AIX
+// the AIX libc expects U202F as LC_MONETARY thousands_sep
+#define THOUSANDS_SEP L"\u202F"
+#else
+#define THOUSANDS_SEP L" "
+#endif
+
 typedef std::money_get<char, cpp17_input_iterator<const char*> > Fn;
 
 class my_facet
@@ -432,7 +437,7 @@ int main(int, char**)
             assert(ex == -1);
         }
         {   // positive
-            std::wstring v = convert_thousands_sep(L"1 234 567,89 ");
+            std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 ");
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
             std::ios_base::iostate err = std::ios_base::goodbit;
@@ -443,7 +448,7 @@ int main(int, char**)
             assert(ex == 123456789);
         }
         {   // negative
-            std::wstring v = convert_thousands_sep(L"-1 234 567,89");
+            std::wstring v = convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89");
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
             std::ios_base::iostate err = std::ios_base::goodbit;
@@ -512,7 +517,7 @@ int main(int, char**)
             assert(ex == -1);
         }
         {   // positive, showbase
-            std::wstring v = convert_thousands_sep(L"1 234 567,89 \u20ac");  // EURO SIGN
+            std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac");  // EURO SIGN
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
             std::ios_base::iostate err = std::ios_base::goodbit;
@@ -523,7 +528,7 @@ int main(int, char**)
             assert(ex == 123456789);
         }
         {   // positive, showbase
-            std::wstring v = convert_thousands_sep(L"1 234 567,89 \u20ac");  // EURO SIGN
+            std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac");  // EURO SIGN
             std::showbase(ios);
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
@@ -536,7 +541,7 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative, showbase
-            std::wstring v = convert_thousands_sep(L"-1 234 567,89 \u20ac");  // EURO SIGN
+            std::wstring v = convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac");  // EURO SIGN
             std::showbase(ios);
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
@@ -549,7 +554,7 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative, showbase
-            std::wstring v = convert_thousands_sep(L"1 234 567,89 EUR -");
+            std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR -");
             std::showbase(ios);
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
@@ -561,7 +566,7 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative, showbase
-            std::wstring v = convert_thousands_sep(L"1 234 567,89 EUR -");
+            std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR -");
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
             std::ios_base::iostate err = std::ios_base::goodbit;
@@ -598,7 +603,7 @@ int main(int, char**)
             assert(ex == -1);
         }
         {   // positive
-            std::wstring v = convert_thousands_sep(L"1 234 567,89 ");
+            std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 ");
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
             std::ios_base::iostate err = std::ios_base::goodbit;
@@ -609,7 +614,7 @@ int main(int, char**)
             assert(ex == 123456789);
         }
         {   // negative
-            std::wstring v = convert_thousands_sep(L"-1 234 567,89");
+            std::wstring v = convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89");
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
             std::ios_base::iostate err = std::ios_base::goodbit;
@@ -678,7 +683,7 @@ int main(int, char**)
             assert(ex == -1);
         }
         {   // positive, showbase
-            std::wstring v = convert_thousands_sep(L"1 234 567,89 EUR");
+            std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR");
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
             std::ios_base::iostate err = std::ios_base::goodbit;
@@ -689,7 +694,7 @@ int main(int, char**)
             assert(ex == 123456789);
         }
         {   // positive, showbase
-            std::wstring v = convert_thousands_sep(L"1 234 567,89 EUR");
+            std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR");
             std::showbase(ios);
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
@@ -702,7 +707,7 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative, showbase
-            std::wstring v = convert_thousands_sep(L"-1 234 567,89 EUR");
+            std::wstring v = convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR");
             std::showbase(ios);
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
@@ -715,7 +720,7 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative, showbase
-            std::wstring v = convert_thousands_sep(L"1 234 567,89 Eu-");
+            std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 Eu-");
             std::showbase(ios);
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
@@ -727,7 +732,7 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative, showbase
-            std::wstring v = convert_thousands_sep(L"1 234 567,89 Eu-");
+            std::wstring v = convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 Eu-");
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
             std::ios_base::iostate err = std::ios_base::goodbit;
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
index 4cdb25728af7d..3db6370b911d4 100644
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
@@ -9,7 +9,6 @@
 // NetBSD does not support LC_MONETARY at the moment
 // XFAIL: netbsd
 
-// XFAIL: LIBCXX-AIX-FIXME
 // XFAIL: LIBCXX-FREEBSD-FIXME
 
 // REQUIRES: locale.zh_CN.UTF-8
@@ -156,7 +155,11 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative one, showbase
+#ifdef _AIX
+            std::string v = "-" + currency_symbol + "0.01";
+#else
             std::string v = currency_symbol + "-0.01";
+#endif
             typedef cpp17_input_iterator<const char*> I;
             long double ex;
             std::ios_base::iostate err = std::ios_base::goodbit;
@@ -167,7 +170,11 @@ int main(int, char**)
             assert(ex == -1);
         }
         {   // negative one, showbase
+#ifdef _AIX
+            std::string v = "-" + currency_symbol + "0.01";
+#else
             std::string v = currency_symbol + "-0.01";
+#endif
             std::showbase(ios);
             typedef cpp17_input_iterator<const char*> I;
             long double ex;
@@ -204,7 +211,11 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative, showbase
+#ifdef _AIX
+            std::string v = "-" + currency_symbol + "1,234,567.89";
+#else
             std::string v = currency_symbol + "-1,234,567.89";
+#endif
             std::showbase(ios);
             typedef cpp17_input_iterator<const char*> I;
             long double ex;
@@ -322,7 +333,7 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative one, showbase
-#ifdef TEST_HAS_GLIBC
+#if defined(TEST_HAS_GLIBC) || defined(_AIX)
             std::string v = "-" + currency_name + "0.01";
 #else
             std::string v = currency_name + "-0.01";
@@ -337,7 +348,7 @@ int main(int, char**)
             assert(ex == -1);
         }
         {   // negative one, showbase
-#ifdef TEST_HAS_GLIBC
+#if defined(TEST_HAS_GLIBC) || defined(_AIX)
             std::string v = "-" + currency_name + "0.01";
 #else
             std::string v = currency_name + "-0.01";
@@ -378,7 +389,7 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative, showbase
-#ifdef TEST_HAS_GLIBC
+#if defined(TEST_HAS_GLIBC) || defined(_AIX)
             std::string v = "-" + currency_name + "1,234,567.89";
 #else
             std::string v = currency_name + "-1,234,567.89";
@@ -507,7 +518,11 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative one, showbase
+#  ifdef _AIX
+            std::wstring v = L"-" + w_currency_symbol + L"0.01";
+#  else
             std::wstring v = w_currency_symbol + L"-0.01";
+#  endif
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
             std::ios_base::iostate err = std::ios_base::goodbit;
@@ -518,7 +533,11 @@ int main(int, char**)
             assert(ex == -1);
         }
         {   // negative one, showbase
+#  ifdef _AIX
+            std::wstring v = L"-" + w_currency_symbol + L"0.01";
+#  else
             std::wstring v = w_currency_symbol + L"-0.01";
+#  endif
             std::showbase(ios);
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
@@ -555,7 +574,11 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative, showbase
+#  ifdef _AIX
+            std::wstring v = L"-" + w_currency_symbol + L"1,234,567.89";
+#  else
             std::wstring v = w_currency_symbol + L"-1,234,567.89";
+#  endif
             std::showbase(ios);
             typedef cpp17_input_iterator<const wchar_t*> I;
             long double ex;
@@ -673,7 +696,7 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative one, showbase
-#ifdef TEST_HAS_GLIBC
+#if defined(TEST_HAS_GLIBC) || defined(_AIX)
             std::wstring v = L"-" + w_currency_name + L"0.01";
 #else
             std::wstring v = w_currency_name + L"-0.01";
@@ -688,7 +711,7 @@ int main(int, char**)
             assert(ex == -1);
         }
         {   // negative one, showbase
-#ifdef TEST_HAS_GLIBC
+#if defined(TEST_HAS_GLIBC) || defined(_AIX)
             std::wstring v = L"-" + w_currency_name + L"0.01";
 #else
             std::wstring v = w_currency_name + L"-0.01";
@@ -729,7 +752,7 @@ int main(int, char**)
             std::noshowbase(ios);
         }
         {   // negative, showbase
-#ifdef TEST_HAS_GLIBC
+#if defined(TEST_HAS_GLIBC) || defined(_AIX)
             std::wstring v = L"-" + w_currency_name + L"1,234,567.89";
 #else
             std::wstring v = w_currency_name + L"-1,234,567.89";
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
index 05b4ee474944a..e36e73f3e8695 100644
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
@@ -11,8 +11,6 @@
 // NetBSD does not support LC_MONETARY at the moment
 // XFAIL: netbsd
 
-// XFAIL: LIBCXX-AIX-FIXME
-
 // REQUIRES: locale.fr_FR.UTF-8
 
 // <locale>
@@ -32,6 +30,13 @@
 #include "platform_support.h" // locale name macros
 #include "test_macros.h"
 
+#ifdef _AIX
+// the AIX libc expects U202F as LC_MONETARY thousands_sep
+#define THOUSANDS_SEP L"\u202F"
+#else
+#define THOUSANDS_SEP L" "
+#endif
+
 typedef std::money_put<char, cpp17_output_iterator<char*> > Fn;
 
 class my_facet
@@ -291,14 +296,14 @@ int main(int, char**)
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, '*', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"1 234 567,89"));
+        assert(ex == convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89"));
     }
     {   // negative
         long double v = -123456789;
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, '*', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"-1 234 567,89"));
+        assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89"));
     }
     {   // zero, showbase
         long double v = 0;
@@ -322,7 +327,7 @@ int main(int, char**)
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, '*', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"1 234 567,89 \u20ac"));
+        assert(ex == convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac"));
     }
     {   // negative, showbase
         long double v = -123456789;
@@ -330,7 +335,7 @@ int main(int, char**)
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, '*', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"-1 234 567,89 \u20ac"));
+        assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac"));
     }
     {   // negative, showbase, left
         long double v = -123456789;
@@ -340,7 +345,7 @@ int main(int, char**)
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, ' ', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"-1 234 567,89 \u20ac     "));
+        assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac     "));
         assert(ios.width() == 0);
     }
     {   // negative, showbase, internal
@@ -351,7 +356,7 @@ int main(int, char**)
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, ' ', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"-1 234 567,89      \u20ac"));
+        assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89      \u20ac"));
         assert(ios.width() == 0);
     }
     {   // negative, showbase, right
@@ -362,7 +367,7 @@ int main(int, char**)
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), false, ios, ' ', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"     -1 234 567,89 \u20ac"));
+        assert(ex == convert_thousands_sep(L"     -1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 \u20ac"));
         assert(ios.width() == 0);
     }
 
@@ -388,14 +393,14 @@ int main(int, char**)
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), true, ios, '*', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"1 234 567,89"));
+        assert(ex == convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89"));
     }
     {   // negative
         long double v = -123456789;
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), true, ios, '*', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"-1 234 567,89"));
+        assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89"));
     }
     {   // zero, showbase
         long double v = 0;
@@ -419,7 +424,7 @@ int main(int, char**)
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), true, ios, '*', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"1 234 567,89 EUR"));
+        assert(ex == convert_thousands_sep(L"1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR"));
     }
     {   // negative, showbase
         long double v = -123456789;
@@ -427,7 +432,7 @@ int main(int, char**)
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), true, ios, '*', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"-1 234 567,89 EUR"));
+        assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR"));
     }
     {   // negative, showbase, left
         long double v = -123456789;
@@ -437,7 +442,7 @@ int main(int, char**)
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), true, ios, ' ', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"-1 234 567,89 EUR   "));
+        assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR   "));
         assert(ios.width() == 0);
     }
     {   // negative, showbase, internal
@@ -448,7 +453,7 @@ int main(int, char**)
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), true, ios, ' ', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"-1 234 567,89    EUR"));
+        assert(ex == convert_thousands_sep(L"-1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89    EUR"));
         assert(ios.width() == 0);
     }
     {   // negative, showbase, right
@@ -459,7 +464,7 @@ int main(int, char**)
         wchar_t str[100];
         cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(str), true, ios, ' ', v);
         std::wstring ex(str, base(iter));
-        assert(ex == convert_thousands_sep(L"   -1 234 567,89 EUR"));
+        assert(ex == convert_thousands_sep(L"   -1" THOUSANDS_SEP "234" THOUSANDS_SEP "567,89 EUR"));
         assert(ios.width() == 0);
     }
 }
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh...
[truncated]

Copy link

github-actions bot commented Jun 8, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

assert(ex == -123456789);
std::noshowbase(ios);
#ifdef _AIX
std::string v = "-" + currency_symbol + "1,234,567.89";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would argue this is a bug in the C library on AIX, is that not possible? If so, we should instead fix this on AIX and mark the test as XFAIL on the versions of AIX where the fix hasn't made it yet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't necessarily disagree with you (though I'm still trying to grok the exact limits placed on the locale definition by the various standards involved). I'll note though what we are doing here is consistent with other platforms with similar locale quirks/bugs are doing in the tests.

IMHO it be nice to keep a consistent approach across tests and platforms here, which I think means doing some variation of either:

  1. Platforms are allow to handle or encode their locale quirks in the tests
  2. The tests only handle standard/ideal locale definitions (i.e. according to something like the Unicode CLDR) and platforms need to opt-out of the tests till such a time as they fix their quirks

Currently, this PR and the existing platforms / locale tests seem to follow approach 1. I wouldn't mind a move to approach 2, but I think that's a change in the status quo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack. I'm concerned about the maintainability of our current approach, but you're right that this patch doesn't make things significantly worse nor does it stray from the status quo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my experience locale definitions are not as "universal" as expected. So we have several tests that hard-code what is used on a platform. I'm a bit surprised U202F was not used already. For example, libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp already does.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit surprised U202F was not used already. For example, libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp already does.

Yeah, it seems to be the case that some tests put that platform specific knowledge into a common place and others platform_support.h and others just hardcode it in the individual test, so even though we fixed in one test others are still affected. I think cleaning that up could help the maintainability concerns here. I'll try to take a look into that as a follow on to this PR.

assert(ex == -123456789);
std::noshowbase(ios);
#ifdef _AIX
std::string v = "-" + currency_symbol + "1,234,567.89";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack. I'm concerned about the maintainability of our current approach, but you're right that this patch doesn't make things significantly worse nor does it stray from the status quo.

Copy link
Contributor

@xingxue-ibm xingxue-ibm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@daltenty daltenty merged commit 9afb09e into llvm:main Jun 14, 2024
53 checks passed
@daltenty daltenty deleted the daltenty/fix-libcxx-locale branch June 14, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants