Skip to content

Commit

Permalink
Merge branch 'master' into RGP-master
Browse files Browse the repository at this point in the history
* master:
  Update amalgamation file
  Test class assignment
  • Loading branch information
rpatters1 committed Oct 22, 2023
2 parents 174388c + 6ca89ec commit 85b526a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
16 changes: 8 additions & 8 deletions Distribution/LuaBridge/LuaBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -1743,17 +1743,17 @@ class BadExpectedAccess<void> : public std::runtime_error
};

template <class E>
class BadExpectedAccess : public BadExpectedAccess<void>
class BadExpectedAccess : public std::runtime_error
{
public:
explicit BadExpectedAccess(E error) noexcept(std::is_nothrow_constructible_v<E, E&&>)
: BadExpectedAccess<void>([](const E& error)
{
if constexpr (detail::has_member_message_v<E>)
return error.message();
else
return std::in_place;
}(error))
: std::runtime_error([](const E& error)
{
if constexpr (detail::has_member_message_v<E>)
return error.message();
else
return "Bad access to expected value";
}(error))
, error_(std::move(error))
{
}
Expand Down
16 changes: 8 additions & 8 deletions Source/LuaBridge/detail/Expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -1010,17 +1010,17 @@ class BadExpectedAccess<void> : public std::runtime_error
};

template <class E>
class BadExpectedAccess : public BadExpectedAccess<void>
class BadExpectedAccess : public std::runtime_error
{
public:
explicit BadExpectedAccess(E error) noexcept(std::is_nothrow_constructible_v<E, E&&>)
: BadExpectedAccess<void>([](const E& error)
{
if constexpr (detail::has_member_message_v<E>)
return error.message();
else
return std::in_place;
}(error))
: std::runtime_error([](const E& error)
{
if constexpr (detail::has_member_message_v<E>)
return error.message();
else
return "Bad access to expected value";
}(error))
, error_(std::move(error))
{
}
Expand Down
12 changes: 12 additions & 0 deletions Tests/Source/ClassTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@ class Bar

} // namespace

TEST_F(ClassTests, Assignment)
{
using BaseClass = Class<int, EmptyBase>;

auto registeredClass = luabridge::getGlobalNamespace(L)
.beginClass<BaseClass>("BaseClass");

registeredClass.addConstructor<void(*)()>();

registeredClass.endClass();
}

TEST_F(ClassTests, IsInstance)
{
using BaseClass = Class<int, EmptyBase>;
Expand Down

0 comments on commit 85b526a

Please sign in to comment.