Skip to content

Commit

Permalink
migrate existing tests to new syntax
Browse files Browse the repository at this point in the history
Signed-off-by: Valentyn Yukhymenko <[email protected]>
  • Loading branch information
BaLiKfromUA committed Aug 27, 2024
1 parent ff458eb commit 7a47147
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
32 changes: 16 additions & 16 deletions libcxx/test/std/experimental/reflection/reflect-invoke.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,31 +271,31 @@ constexpr Number num{42};

// member function with input arguments
static_assert(std::meta::reflect_value(84) ==
reflect_invoke(^Number::plus,
{^num, std::meta::reflect_value(42)}));
reflect_invoke(^^Number::plus,
{^^num, std::meta::reflect_value(42)}));

// operator overload
static_assert(std::meta::reflect_value(84) ==
reflect_invoke(^Number::get_value,
{reflect_invoke(^Number::operator+,
{^num, std::meta::reflect_value(42)})}));
reflect_invoke(^^Number::get_value,
{reflect_invoke(^^Number::operator+,
{^^num, std::meta::reflect_value(42)})}));

// member function without input arguments
static_assert(std::meta::reflect_value(42) ==
reflect_invoke(^Number::get_value,
{^num}));
reflect_invoke(^^Number::get_value,
{^^num}));

// member function called with object reference
constexpr auto num_ref = &num;
static_assert(std::meta::reflect_value(42) ==
reflect_invoke(^Number::get_value,
{^num_ref}));
reflect_invoke(^^Number::get_value,
{^^num_ref}));

// template member function
static_assert(std::meta::reflect_value(84) ==
reflect_invoke(^Number::multiply,
{^int},
{^num, std::meta::reflect_value(2)}));
reflect_invoke(^^Number::multiply,
{^^int},
{^^num, std::meta::reflect_value(2)}));

// Invoking Base::fn() with an object of type Child
struct IsReal {
Expand All @@ -314,11 +314,11 @@ struct FloatNumber : public Number, IsReal{

constexpr FloatNumber childNumber{42};
static_assert(std::meta::reflect_value(42) ==
reflect_invoke(^Number::get_value,
{^childNumber}));
reflect_invoke(^^Number::get_value,
{^^childNumber}));
static_assert(std::meta::reflect_value(true) ==
reflect_invoke(^IsReal::is_real,
{^childNumber}));
reflect_invoke(^^IsReal::is_real,
{^^childNumber}));

} // namespace non_static_member_functions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03 || c++11 || c++14 || c++17 || c++20
// ADDITIONAL_COMPILE_FLAGS: -freflection
// ADDITIONAL_COMPILE_FLAGS: -freflection -freflection-new-syntax
// ADDITIONAL_COMPILE_FLAGS: -Wno-unneeded-internal-declaration -Wno-unused-variable -Wno-unused-value

// <experimental/reflection>
Expand Down Expand Up @@ -39,27 +39,27 @@ int main() {
// non-static member functions
// ======================
constexpr A expectedClass{};
reflect_invoke(^A::fn, {^expectedClass}); // ok
reflect_invoke(^^A::fn, {^^expectedClass}); // ok

reflect_invoke(^A::void_fn, {^expectedClass});
reflect_invoke(^^A::void_fn, {^^expectedClass});
// expected-error-re@-1 {{call to consteval function 'std::meta::reflect_invoke<{{.*}}>' is not a constant expression}}
// expected-note@-2 {{cannot invoke reflection of void-returning function}}

reflect_invoke(^A::fn, {});
reflect_invoke(^^A::fn, {});
// expected-error-re@-1 {{call to consteval function 'std::meta::reflect_invoke<{{.*}}>' is not a constant expression}}
// expected-note@-2 {{expected related object reflection as a first argument for invoking non-static member function}}

reflect_invoke(^A::fn, {std::meta::reflect_value(42)});
reflect_invoke(^^A::fn, {std::meta::reflect_value(42)});
// expected-error-re@-1 {{call to consteval function 'std::meta::reflect_invoke<{{.*}}>' is not a constant expression}}
// expected-note@-2 {{expected related object reflection as a first argument for invoking non-static member function}}

constexpr B differentClass{};
reflect_invoke(^A::fn, {^differentClass});
reflect_invoke(^^A::fn, {^^differentClass});
// expected-error-re@-1 {{call to consteval function 'std::meta::reflect_invoke<{{.*}}>' is not a constant expression}}
// expected-note@-2 {{method is not a member of given object reflection}}

constexpr NS::A differentNamespaceClass{};
reflect_invoke(^A::fn, {^differentNamespaceClass});
reflect_invoke(^^A::fn, {^^differentNamespaceClass});
// expected-error-re@-1 {{call to consteval function 'std::meta::reflect_invoke<{{.*}}>' is not a constant expression}}
// expected-note@-2 {{method is not a member of given object reflection}}
}

0 comments on commit 7a47147

Please sign in to comment.