-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc++] Remove obsolete locale-specific regex tests #159590
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
Conversation
After a recent macOS update, several of the locale-specific regex tests started failing. These tests were mainly testing two locale specific features of regular expressions: - A character class like `[=x=]` matches any character that is considered equivalent to `x` according to the collation rules of the current locale. - A character class like `[[.ch.]]` matches anything that is equivalent to `ch` (whether as two letters or as a single collation element) in the current locale. However, these tests were relying on platform-specific localization data, specifically they were only working with older macOS localization data. As can be seen from the numerous XFAILs, most mainstream platforms didn't actually pass this test. After the macOS update, macOS itself also doesn't pass these tests anymore. I looked at whether there are locales where these tests would still make sense, and I couldn't find any. I am not a localization expert, but it appears that only e.g. the traditional Spanish locale considers `[.ch.]` to be a single collation element. Therefore, it seems that the locale specific part of these tests is not relevant anymore, so this patch removes them. The patch also moves some tests for equivalence classes inside character classes to their non locale-specific tests, since that feature was not covered there. Finally, the lookup_collatename.pass.cpp test was fixed by removing an assertion that `ch` is a collation element in the CZ locale, which seems to not be the case in recent localization data (and appears to be the root cause for about half the failures in these tests).
@llvm/pr-subscribers-libcxx Author: Louis Dionne (ldionne) ChangesAfter a recent macOS update, several of the locale-specific regex tests started failing. These tests were mainly testing two locale specific features of regular expressions:
However, these tests were relying on platform-specific localization data, specifically they were only working with older macOS localization data. As can be seen from the numerous XFAILs, most mainstream platforms didn't actually pass this test. After the macOS update, macOS itself also doesn't pass these tests anymore. I looked at whether there are locales where these tests would still make sense, and I couldn't find any. I am not a localization expert, but it appears that only e.g. the traditional Spanish locale considers The patch also moves some tests for equivalence classes inside character classes to their non locale-specific tests, since that feature was not covered there. Finally, the lookup_collatename.pass.cpp test was fixed by removing an assertion that Patch is 61.31 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/159590.diff 17 Files Affected:
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/awk.locale.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/awk.locale.pass.cpp
deleted file mode 100644
index 8c2875de01c52..0000000000000
--- a/libcxx/test/std/re/re.alg/re.alg.match/awk.locale.pass.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// <regex>
-
-// template <class BidirectionalIterator, class Allocator, class charT,
-// class traits>
-// bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
-// match_results<BidirectionalIterator, Allocator>& m,
-// const basic_regex<charT, traits>& e,
-// regex_constants::match_flag_type flags
-// = regex_constants::match_default);
-
-// TODO: investigation needed
-// TODO(netbsd): incomplete support for locales
-// XFAIL: target={{.*}}-linux-gnu{{.*}}, netbsd, freebsd
-// XFAIL: target={{.*}}-amazon-linux{{.*}}
-// XFAIL: target={{.*}}-apple-{{.*}}
-// REQUIRES: locale.cs_CZ.ISO8859-2
-
-#include <regex>
-#include <cassert>
-#include "test_macros.h"
-#include "test_iterators.h"
-
-#include "platform_support.h" // locale name macros
-
-int main(int, char**)
-{
- std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
- {
- std::cmatch m;
- const char s[] = "m";
-// AIX supports character equivalence classes. What the contents of the class are depends
-// on the locale and the standards do not specify any locale other than C/POSIX.
-#if defined(_AIX)
- assert(std::regex_match(s, m,
- std::regex("[a[=m=]z]", std::regex_constants::awk)));
-#else
- assert(std::regex_match(s, m,
- std::regex("[a[=M=]z]", std::regex_constants::awk)));
-#endif
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert((std::size_t)m.length(0) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::cmatch m;
- const char s[] = "Ch";
- assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
- std::regex_constants::awk | std::regex_constants::icase)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert((std::size_t)m.length(0) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- std::locale::global(std::locale("C"));
- {
- std::cmatch m;
- const char s[] = "m";
- assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
- std::regex_constants::awk)));
- assert(m.size() == 0);
- }
-
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
- {
- std::wcmatch m;
- const wchar_t s[] = L"m";
-#if defined(_AIX)
- assert(std::regex_match(s, m, std::wregex(L"[a[=m=]z]",
- std::regex_constants::awk)));
-#else
- assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
- std::regex_constants::awk)));
-#endif
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert((std::size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
-//TODO: Need to be investigated for AIX OS
-#if !defined(_AIX)
- {
- std::wcmatch m;
- const wchar_t s[] = L"Ch";
- assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
- std::regex_constants::awk | std::regex_constants::icase)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert((std::size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
-#endif
- std::locale::global(std::locale("C"));
- {
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
- std::regex_constants::awk)));
- assert(m.size() == 0);
- }
-#endif // TEST_HAS_NO_WIDE_CHARACTERS
- return 0;
-}
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/awk.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/awk.pass.cpp
index 988beec15e644..024738258c050 100644
--- a/libcxx/test/std/re/re.alg/re.alg.match/awk.pass.cpp
+++ b/libcxx/test/std/re/re.alg/re.alg.match/awk.pass.cpp
@@ -573,6 +573,29 @@ int main(int, char**)
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m,
+ std::regex("[a[=m=]z]", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert((std::size_t)m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m,
+ std::regex("[a[=M=]z]", std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
{
std::cmatch m;
const char s[] = "-";
@@ -1215,6 +1238,29 @@ int main(int, char**)
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=m=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert((std::size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::awk)));
+ assert(m.size() == 0);
+ }
{
std::wcmatch m;
const wchar_t s[] = L"-";
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/basic.locale.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/basic.locale.pass.cpp
deleted file mode 100644
index 9002681547b8d..0000000000000
--- a/libcxx/test/std/re/re.alg/re.alg.match/basic.locale.pass.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// NetBSD does not support LC_COLLATE at the moment
-// XFAIL: netbsd
-// XFAIL: LIBCXX-AIX-FIXME
-
-// REQUIRES: locale.cs_CZ.ISO8859-2
-
-// <regex>
-
-// template <class BidirectionalIterator, class Allocator, class charT, class traits>
-// bool
-// regex_match(BidirectionalIterator first, BidirectionalIterator last,
-// match_results<BidirectionalIterator, Allocator>& m,
-// const basic_regex<charT, traits>& e,
-// regex_constants::match_flag_type flags = regex_constants::match_default);
-
-// TODO: investigation needed
-// XFAIL: target={{.*}}-linux-gnu{{.*}}, freebsd
-// XFAIL: target={{.*}}-amazon-linux{{.*}}
-// XFAIL: target={{.*}}-apple-{{.*}}
-
-#include <regex>
-#include <cassert>
-#include "test_macros.h"
-#include "test_iterators.h"
-
-#include "platform_support.h" // locale name macros
-
-int main(int, char**)
-{
- std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
- {
- std::cmatch m;
- const char s[] = "m";
- assert(std::regex_match(s, m, std::regex("[a[=M=]z]",
- std::regex_constants::basic)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::cmatch m;
- const char s[] = "Ch";
- assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
- std::regex_constants::basic | std::regex_constants::icase)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- std::locale::global(std::locale("C"));
- {
- std::cmatch m;
- const char s[] = "m";
- assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
- std::regex_constants::basic)));
- assert(m.size() == 0);
- }
-
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
- {
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
- std::regex_constants::basic)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::wcmatch m;
- const wchar_t s[] = L"Ch";
- assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
- std::regex_constants::basic | std::regex_constants::icase)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- std::locale::global(std::locale("C"));
- {
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
- std::regex_constants::basic)));
- assert(m.size() == 0);
- }
-#endif // TEST_HAS_NO_WIDE_CHARACTERS
-
- return 0;
-}
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp
index 9765a07f2e4fe..fd91866b9209b 100644
--- a/libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp
+++ b/libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp
@@ -575,6 +575,29 @@ int main(int, char**)
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=m=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
{
std::cmatch m;
const char s[] = "-";
@@ -1203,6 +1226,29 @@ int main(int, char**)
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=m=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+ std::regex_constants::basic)));
+ assert(m.size() == 0);
+ }
{
std::wcmatch m;
const wchar_t s[] = L"-";
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/ecma.locale.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/ecma.locale.pass.cpp
deleted file mode 100644
index 2e6f7fd285ae4..0000000000000
--- a/libcxx/test/std/re/re.alg/re.alg.match/ecma.locale.pass.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// NetBSD does not support LC_COLLATE at the moment
-// XFAIL: netbsd
-// XFAIL: LIBCXX-AIX-FIXME
-
-// REQUIRES: locale.cs_CZ.ISO8859-2
-
-// <regex>
-
-// template <class BidirectionalIterator, class Allocator, class charT, class traits>
-// bool
-// regex_match(BidirectionalIterator first, BidirectionalIterator last,
-// match_results<BidirectionalIterator, Allocator>& m,
-// const basic_regex<charT, traits>& e,
-// regex_constants::match_flag_type flags = regex_constants::match_default);
-
-// TODO: investigation needed
-// XFAIL: target={{.*}}-linux-gnu{{.*}}, freebsd
-// XFAIL: target={{.*}}-amazon-linux{{.*}}
-// XFAIL: target={{.*}}-apple-{{.*}}
-
-#include <regex>
-#include <cassert>
-#include "test_macros.h"
-#include "test_iterators.h"
-
-#include "platform_support.h" // locale name macros
-
-int main(int, char**)
-{
- std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
- {
- std::cmatch m;
- const char s[] = "m";
- assert(std::regex_match(s, m, std::regex("[a[=M=]z]")));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::cmatch m;
- const char s[] = "Ch";
- assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
- std::regex_constants::icase)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- std::locale::global(std::locale("C"));
- {
- std::cmatch m;
- const char s[] = "m";
- assert(!std::regex_match(s, m, std::regex("[a[=M=]z]")));
- assert(m.size() == 0);
- }
-
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2));
- {
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]")));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::wcmatch m;
- const wchar_t s[] = L"Ch";
- assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
- std::regex_constants::icase)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- std::locale::global(std::locale("C"));
- {
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]")));
...
[truncated]
|
You can test this locally with the following command:git-clang-format --diff origin/main HEAD --extensions cpp -- libcxx/test/std/re/re.alg/re.alg.match/awk.pass.cpp libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp libcxx/test/std/re/re.alg/re.alg.match/extended.pass.cpp libcxx/test/std/re/re.alg/re.alg.search/awk.pass.cpp libcxx/test/std/re/re.alg/re.alg.search/basic.pass.cpp libcxx/test/std/re/re.alg/re.alg.search/ecma.pass.cpp libcxx/test/std/re/re.alg/re.alg.search/extended.pass.cpp libcxx/test/std/re/re.traits/lookup_collatename.pass.cpp
View the diff from clang-format here.diff --git a/libcxx/test/std/re/re.alg/re.alg.match/awk.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/awk.pass.cpp
index 024738258..ef86db040 100644
--- a/libcxx/test/std/re/re.alg/re.alg.match/awk.pass.cpp
+++ b/libcxx/test/std/re/re.alg/re.alg.match/awk.pass.cpp
@@ -574,27 +574,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::cmatch m;
- const char s[] = "m";
- assert(std::regex_match(s, m,
- std::regex("[a[=m=]z]", std::regex_constants::awk)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert((std::size_t)m.length(0) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::cmatch m;
- const char s[] = "m";
- assert(!std::regex_match(s, m,
- std::regex("[a[=M=]z]", std::regex_constants::awk)));
- assert(m.size() == 0);
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=m=]z]", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert((std::size_t)m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]", std::regex_constants::awk)));
+ assert(m.size() == 0);
}
{
std::cmatch m;
@@ -1239,27 +1237,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(std::regex_match(s, m, std::wregex(L"[a[=m=]z]",
- std::regex_constants::awk)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert((std::size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
- std::regex_constants::awk)));
- assert(m.size() == 0);
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=m=]z]", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert((std::size_t)m.length(0) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]", std::regex_constants::awk)));
+ assert(m.size() == 0);
}
{
std::wcmatch m;
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp
index fd91866b9..c0433789b 100644
--- a/libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp
+++ b/libcxx/test/std/re/re.alg/re.alg.match/basic.pass.cpp
@@ -576,27 +576,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::cmatch m;
- const char s[] = "m";
- assert(std::regex_match(s, m, std::regex("[a[=m=]z]",
- std::regex_constants::basic)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::cmatch m;
- const char s[] = "m";
- assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
- std::regex_constants::basic)));
- assert(m.size() == 0);
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=m=]z]", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]", std::regex_constants::basic)));
+ assert(m.size() == 0);
}
{
std::cmatch m;
@@ -1227,27 +1225,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(std::regex_match(s, m, std::wregex(L"[a[=m=]z]",
- std::regex_constants::basic)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
- std::regex_constants::basic)));
- assert(m.size() == 0);
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=m=]z]", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]", std::regex_constants::basic)));
+ assert(m.size() == 0);
}
{
std::wcmatch m;
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
index 799a36242..8e4755330 100644
--- a/libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
+++ b/libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
@@ -564,25 +564,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::cmatch m;
- const char s[] = "m";
- assert(std::regex_match(s, m, std::regex("[a[=m=]z]")));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=m=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
}
{
- std::cmatch m;
- const char s[] = "m";
- assert(!std::regex_match(s, m, std::regex("[a[=M=]z]")));
- assert(m.size() == 0);
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 0);
}
{
std::cmatch m;
@@ -1248,25 +1248,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(std::regex_match(s, m, std::wregex(L"[a[=m=]z]")));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=m=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
}
{
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]")));
- assert(m.size() == 0);
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 0);
}
{
std::wcmatch m;
diff --git a/libcxx/test/std/re/re.alg/re.alg.match/extended.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.match/extended.pass.cpp
index e800fa88d..862a976a9 100644
--- a/libcxx/test/std/re/re.alg/re.alg.match/extended.pass.cpp
+++ b/libcxx/test/std/re/re.alg/re.alg.match/extended.pass.cpp
@@ -591,27 +591,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::cmatch m;
- const char s[] = "m";
- assert(std::regex_match(s, m, std::regex("[a[=m=]z]",
- std::regex_constants::extended)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::cmatch m;
- const char s[] = "m";
- assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
- std::regex_constants::extended)));
- assert(m.size() == 0);
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_match(s, m, std::regex("[a[=m=]z]", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_match(s, m, std::regex("[a[=M=]z]", std::regex_constants::extended)));
+ assert(m.size() == 0);
}
{
std::cmatch m;
@@ -1258,27 +1256,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(std::regex_match(s, m, std::wregex(L"[a[=m=]z]",
- std::regex_constants::extended)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
- std::regex_constants::extended)));
- assert(m.size() == 0);
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_match(s, m, std::wregex(L"[a[=m=]z]", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]", std::regex_constants::extended)));
+ assert(m.size() == 0);
}
{
std::wcmatch m;
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/awk.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/awk.pass.cpp
index 904ba0661..5d0bcec15 100644
--- a/libcxx/test/std/re/re.alg/re.alg.search/awk.pass.cpp
+++ b/libcxx/test/std/re/re.alg/re.alg.search/awk.pass.cpp
@@ -646,27 +646,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::cmatch m;
- const char s[] = "m";
- assert(std::regex_search(s, m, std::regex("[a[=m=]z]",
- std::regex_constants::awk)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::cmatch m;
- const char s[] = "m";
- assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
- std::regex_constants::awk)));
- assert(m.size() == 0);
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=m=]z]", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]", std::regex_constants::awk)));
+ assert(m.size() == 0);
}
{
std::cmatch m;
@@ -1401,27 +1399,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(std::regex_search(s, m, std::wregex(L"[a[=m=]z]",
- std::regex_constants::awk)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
- std::regex_constants::awk)));
- assert(m.size() == 0);
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=m=]z]", std::regex_constants::awk)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]", std::regex_constants::awk)));
+ assert(m.size() == 0);
}
{
std::wcmatch m;
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/basic.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/basic.pass.cpp
index 74b4d6341..84e94d906 100644
--- a/libcxx/test/std/re/re.alg/re.alg.search/basic.pass.cpp
+++ b/libcxx/test/std/re/re.alg/re.alg.search/basic.pass.cpp
@@ -648,27 +648,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::cmatch m;
- const char s[] = "m";
- assert(std::regex_search(s, m, std::regex("[a[=m=]z]",
- std::regex_constants::basic)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::cmatch m;
- const char s[] = "m";
- assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
- std::regex_constants::basic)));
- assert(m.size() == 0);
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=m=]z]", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]", std::regex_constants::basic)));
+ assert(m.size() == 0);
}
{
std::cmatch m;
@@ -1389,27 +1387,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(std::regex_search(s, m, std::wregex(L"[a[=m=]z]",
- std::regex_constants::basic)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
- std::regex_constants::basic)));
- assert(m.size() == 0);
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=m=]z]", std::regex_constants::basic)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]", std::regex_constants::basic)));
+ assert(m.size() == 0);
}
{
std::wcmatch m;
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/ecma.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/ecma.pass.cpp
index ee88d1138..f58730226 100644
--- a/libcxx/test/std/re/re.alg/re.alg.search/ecma.pass.cpp
+++ b/libcxx/test/std/re/re.alg/re.alg.search/ecma.pass.cpp
@@ -631,25 +631,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::cmatch m;
- const char s[] = "m";
- assert(std::regex_search(s, m, std::regex("[a[=m=]z]")));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::cmatch m;
- const char s[] = "m";
- assert(!std::regex_search(s, m, std::regex("[a[=M=]z]")));
- assert(m.size() == 0);
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=m=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]")));
+ assert(m.size() == 0);
}
{
std::cmatch m;
@@ -1393,25 +1393,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(std::regex_search(s, m, std::wregex(L"[a[=m=]z]")));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]")));
- assert(m.size() == 0);
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=m=]z]")));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]")));
+ assert(m.size() == 0);
}
{
std::wcmatch m;
diff --git a/libcxx/test/std/re/re.alg/re.alg.search/extended.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/extended.pass.cpp
index 73c37267e..39be41e4b 100644
--- a/libcxx/test/std/re/re.alg/re.alg.search/extended.pass.cpp
+++ b/libcxx/test/std/re/re.alg/re.alg.search/extended.pass.cpp
@@ -664,27 +664,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::cmatch m;
- const char s[] = "m";
- assert(std::regex_search(s, m, std::regex("[a[=m=]z]",
- std::regex_constants::extended)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::cmatch m;
- const char s[] = "m";
- assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
- std::regex_constants::extended)));
- assert(m.size() == 0);
+ std::cmatch m;
+ const char s[] = "m";
+ assert(std::regex_search(s, m, std::regex("[a[=m=]z]", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "m";
+ assert(!std::regex_search(s, m, std::regex("[a[=M=]z]", std::regex_constants::extended)));
+ assert(m.size() == 0);
}
{
std::cmatch m;
@@ -1421,27 +1419,25 @@ int main(int, char**)
assert(m.str(0) == s);
}
{
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(std::regex_search(s, m, std::wregex(L"[a[=m=]z]",
- std::regex_constants::extended)));
- assert(m.size() == 1);
- assert(!m.prefix().matched);
- assert(m.prefix().first == s);
- assert(m.prefix().second == m[0].first);
- assert(!m.suffix().matched);
- assert(m.suffix().first == m[0].second);
- assert(m.suffix().second == m[0].second);
- assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
- assert(m.position(0) == 0);
- assert(m.str(0) == s);
- }
- {
- std::wcmatch m;
- const wchar_t s[] = L"m";
- assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
- std::regex_constants::extended)));
- assert(m.size() == 0);
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(std::regex_search(s, m, std::wregex(L"[a[=m=]z]", std::regex_constants::extended)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) >= 0 && static_cast<std::size_t>(m.length(0)) == std::char_traits<wchar_t>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::wcmatch m;
+ const wchar_t s[] = L"m";
+ assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]", std::regex_constants::extended)));
+ assert(m.size() == 0);
}
{
std::wcmatch m;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I'm fine with this, since it improves the actual situation we're in, but conceptually we seem to loose some coverage. I guess I'm fine with this as-is (and an issue to follow up on this), since these tests are practically useless at the moment.
|
||
int main(int, char**) | ||
{ | ||
std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks to me like we're "losing" quite a bit of coverage here. Would it maybe make sense to have some custom locales for this kind of stuff instead? AFAICT the point of these tests is to make sure the appropriate localization APIs are used, not that a locale behaves in a particular way. That would make our localization tests significantly more robust and avoid a bunch of #ifdefs
for the behaviour of the different platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the idea of creating our own locale for testing makes a lot of sense. It could greatly reduce the complexity associated with locale testing everywhere in the test suite.
That being said, after spending about an hour reading on how to create locales and doing some research on how that's done on macOS, it seems to be pretty platform-dependent. There's also the part of letting the custom local be picked up I haven't managed to get working yet. There may be an easy to way to do it, but it's not very well documented unless I missed something obvious. IIUC we'd have to do the same for each of the platforms that we support (hopefully several platforms share a similar behavior).
For the time being, I've created #159836 to track this. While I think it would be a good idea, I think I'd want to bundle that work along with other improvements to the localization facilities, otherwise the value provided for the amount of time invested seems like a difficult pitch.
After a recent macOS update, several of the locale-specific regex tests started failing. These tests were mainly testing two locale specific features of regular expressions: - A character class like `[=x=]` matches any character that is considered equivalent to `x` according to the collation rules of the current locale. - A character class like `[[.ch.]]` matches anything that is equivalent to `ch` (whether as two letters or as a single collation element) in the current locale. However, these tests were relying on platform-specific localization data, specifically they were only working with older macOS localization data. As can be seen from the numerous XFAILs, most mainstream platforms didn't actually pass this test. After the macOS update, macOS itself also doesn't pass these tests anymore. I looked at whether there are locales where these tests would still make sense, and I couldn't find any. I am not a localization expert, but it appears that only legacy locales like the traditional Spanish locale (which isn't commonly shipped on systems anymore) considers `[.ch.]` to be a single collation element. Therefore, it seems that the locale specific part of these tests is not relevant anymore, and this patch removes them. The patch also moves some tests for equivalence classes inside character classes to their non locale-specific tests, since that feature was not covered there. Finally, the lookup_collatename.pass.cpp test was fixed by removing an assertion that `ch` is a collation element in the CZ locale, which seems to not be the case in recent localization data (and appears to be the root cause for about half the failures in these tests).
After a recent macOS update, several of the locale-specific regex tests started failing. These tests were mainly testing two locale specific features of regular expressions:
A character class like
[=x=]
matches any character that is considered equivalent tox
according to the collation rules of the current locale.A character class like
[[.ch.]]
matches anything that is equivalent toch
(whether as two letters or as a single collation element) in the current locale.However, these tests were relying on platform-specific localization data, specifically they were only working with older macOS localization data. As can be seen from the numerous XFAILs, most mainstream platforms didn't actually pass this test. After the macOS update, macOS itself also doesn't pass these tests anymore.
I looked at whether there are locales where these tests would still make sense, and I couldn't find any. I am not a localization expert, but it appears that only legacy locales like the traditional Spanish locale (which isn't commonly shipped on systems anymore) considers
[.ch.]
to be a single collation element. Therefore, it seems that the locale specific part of these tests is not relevant anymore, and this patch removes them.The patch also moves some tests for equivalence classes inside character classes to their non locale-specific tests, since that feature was not covered there.
Finally, the lookup_collatename.pass.cpp test was fixed by removing an assertion that
ch
is a collation element in the CZ locale, which seems to not be the case in recent localization data (and appears to be the root cause for about half the failures in these tests).