Skip to content

[libc++] Add missing CPO tests for range adaptors #149557

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 6 commits into from
Jul 25, 2025

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Jul 18, 2025

No description provided.

@ldionne ldionne requested a review from huixie90 July 18, 2025 18:35
@ldionne ldionne requested a review from a team as a code owner July 18, 2025 18:35
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jul 18, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 18, 2025

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/149557.diff

1 Files Affected:

  • (modified) libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp (+30-10)
diff --git a/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp b/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp
index 3f4317a724add..9889ff2e59607 100644
--- a/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp
+++ b/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp
@@ -15,6 +15,7 @@
 #include <concepts>
 #include <iterator>
 #include <ranges>
+#include <sstream>
 #include <type_traits>
 #include <utility>
 
@@ -26,7 +27,7 @@ constexpr bool test(CPO& o, Args&&...) {
   static_assert(std::is_trivially_copyable_v<CPO>);
   static_assert(std::is_trivially_default_constructible_v<CPO>);
 
-  auto p = o;
+  auto p  = o;
   using T = decltype(p);
 
   // The type of a customization point object, ignoring cv-qualifiers, shall model semiregular.
@@ -43,7 +44,8 @@ constexpr bool test(CPO& o, Args&&...) {
 
 int a[10];
 int arrays[10][10];
-//std::pair<int, int> pairs[10];
+std::pair<int, int> pairs[10];
+std::istringstream stream;
 
 // [concept.swappable]
 static_assert(test(std::ranges::swap, a, a));
@@ -77,23 +79,41 @@ static_assert(test(std::ranges::ssize, a));
 
 // [range.factories]
 // views::empty<T> is not a CPO
-static_assert(test(std::views::iota, 1));
 static_assert(test(std::views::iota, 1, 10));
-//static_assert(test(std::views::istream<int>, 1);
+static_assert(test(std::views::iota, 1));
+static_assert(test(std::views::istream<int>, stream));
+static_assert(test(std::views::repeat, 1));
 static_assert(test(std::views::single, 4));
 
 // [range.adaptors]
+// static_assert(test(std::views::adjacent_transform<2>, [](int x, int y) { return x + y; }, a));
+// static_assert(test(std::views::adjacent<2>, a));
 static_assert(test(std::views::all, a));
+// static_assert(test(std::views::as_const, a));
+static_assert(test(std::views::as_rvalue, a));
+// static_assert(test(std::views::cache_latest, a));
+// static_assert(test(std::views::cartesian_product, a, a, a));
+static_assert(test(std::views::chunk_by, a, [](int x, int y) { return x < y; }));
+// static_assert(test(std::views::chunk, a, 1));
 static_assert(test(std::views::common, a));
+// static_assert(test(std::views::concat, a, a));
 static_assert(test(std::views::counted, a, 10));
+static_assert(test(std::views::drop_while, a, [](int x) { return x < 10; }));
 static_assert(test(std::views::drop, a, 10));
-//static_assert(test(std::views::drop_while, a, [](int x){ return x < 10; }));
-//static_assert(test(std::views::elements<0>, pairs));
-static_assert(test(std::views::filter, a, [](int x){ return x < 10; }));
+static_assert(test(std::views::elements<0>, pairs));
+// static_assert(test(std::views::enumerate, a));
+static_assert(test(std::views::filter, a, [](int x) { return x < 10; }));
+static_assert(test(std::views::join_with, 1));
 static_assert(test(std::views::join, arrays));
-//static_assert(test(std::views::split, a, 4));
+static_assert(test(std::views::keys, pairs));
 static_assert(test(std::views::lazy_split, a, 4));
 static_assert(test(std::views::reverse, a));
+static_assert(test(std::views::split, a, 4));
+// static_assert(test(std::views::stride, a, 1));
+static_assert(test(std::views::take_while, a, [](int x) { return x < 10; }));
 static_assert(test(std::views::take, a, 10));
-//static_assert(test(std::views::take_while, a, [](int x){ return x < 10; }));
-static_assert(test(std::views::transform, a, [](int x){ return x + 1; }));
+// static_assert(test(std::views::to_input, a));
+static_assert(test(std::views::transform, a, [](int x) { return x + 1; }));
+static_assert(test(std::views::values, pairs));
+// static_assert(test(std::views::zip_transform, [](int x, int y) { return x + y; }, a, a));
+static_assert(test(std::views::zip, a, a));

Copy link
Contributor

@frederick-vs-ja frederick-vs-ja left a comment

Choose a reason for hiding this comment

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

Thanks! I pushed some conflict-resolving changes.

It seems that static_assert(test(std::views::repeat, 1)); wasn't guarded and compiled in C++20. Perhaps we can look into this later.

@frederick-vs-ja
Copy link
Contributor

It seems that static_assert(test(std::views::repeat, 1)); wasn't guarded and compiled in C++20. Perhaps we can look into this later.

No. It didn't. It seems that the generic-cxx20 set just didn't run in CI...

@Zingam
Copy link
Contributor

Zingam commented Jul 22, 2025

Thanks! I pushed some conflict-resolving changes.

Excuse me for the off-topic question. What is required to push to other people's PR like that? I tried to push into mine Zingam -> H-G-Hristov and I got "no access" error or similar?

@ldionne
Copy link
Member Author

ldionne commented Jul 24, 2025

It seems that static_assert(test(std::views::repeat, 1)); wasn't guarded and compiled in C++20. Perhaps we can look into this later.

No. It didn't. It seems that the generic-cxx20 set just didn't run in CI...

It definitely ran on the latest version of the patch: https://github.com/llvm/llvm-project/actions/runs/16436783672/job/46449613521?pr=149557

Thanks! I pushed some conflict-resolving changes.

Excuse me for the off-topic question. What is required to push to other people's PR like that? I tried to push into mine Zingam -> H-G-Hristov and I got "no access" error or similar?

I think you might need to be marked as a "maintainer" of the repo, perhaps by being in the reviewers-libcxx group. I'm not certain.

Comment on lines +93 to +96
#if TEST_STD_VER >= 23
static_assert(test(std::views::repeat, 1));
#endif

Copy link
Contributor

Choose a reason for hiding this comment

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

If tests are grouped by the C++ version, should this be moved down?

Copy link
Contributor

@frederick-vs-ja frederick-vs-ja Jul 25, 2025

Choose a reason for hiding this comment

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

I think tests are intended to be grouped by sections ([range.factories], [range.adaptors]) first and then the standard modes. But this is up to @ldionne.

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 pretty neutral on this, but the tests were previously grouped as described by @frederick-vs-ja , so I decided to stick to that.

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'll merge this now, but I am happy to adjust as a NFC follow-up if we agree on another organization.

@ldionne ldionne merged commit 1d0aa5f into llvm:main Jul 25, 2025
77 checks passed
@ldionne ldionne deleted the review/add-missing-views-to-cpo-tests branch July 25, 2025 17:29
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jul 28, 2025
ajaden-codes pushed a commit to Jaddyen/llvm-project that referenced this pull request Jul 28, 2025
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