mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
better tests, wee
This commit is contained in:
parent
56ed859d3f
commit
2640f670b6
|
@ -20,8 +20,8 @@
|
|||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// This file was generated with a script.
|
||||
// Generated 2016-08-21 23:25:04.369074 UTC
|
||||
// This header was generated with sol v2.11.6 (revision 6243cbe)
|
||||
// Generated 2016-08-22 02:15:33.510154 UTC
|
||||
// This header was generated with sol v2.11.5 (revision 56ed859)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||
|
@ -3968,7 +3968,7 @@ namespace sol {
|
|||
std::is_lvalue_reference<T>,
|
||||
meta::neg<std::is_const<T>>,
|
||||
meta::neg<is_lua_primitive<meta::unqualified_t<T>>>,
|
||||
meta::neg<is_unique_usertype<T>>
|
||||
meta::neg<is_unique_usertype<meta::unqualified_t<T>>>
|
||||
> use_reference_tag;
|
||||
return pusher<std::conditional_t<use_reference_tag::value, detail::as_reference_tag, meta::unqualified_t<T>>>{}.push(L, std::forward<T>(t), std::forward<Args>(args)...);
|
||||
}
|
||||
|
|
|
@ -1406,3 +1406,36 @@ TEST_CASE("usertype/inheritance", "test that metatables are properly inherited")
|
|||
REQUIRE(b == 10);
|
||||
REQUIRE(a == 5);
|
||||
}
|
||||
|
||||
TEST_CASE("usertype/unique_usertype-check", "make sure unique usertypes don't get pushed as references with function calls and the like") {
|
||||
class Entity {
|
||||
public:
|
||||
std::string GetName() {
|
||||
return "Charmander";
|
||||
}
|
||||
};
|
||||
|
||||
sol::state lua;
|
||||
lua.open_libraries(sol::lib::base, sol::lib::math, sol::lib::string, sol::lib::io);
|
||||
|
||||
lua.new_usertype<Entity>("Entity",
|
||||
"new", sol::no_constructor,
|
||||
"get_name", &Entity::GetName
|
||||
);
|
||||
|
||||
lua.script(R"(
|
||||
function my_func(entity)
|
||||
print("INSIDE LUA")
|
||||
print(entity:get_name())
|
||||
end
|
||||
)");
|
||||
|
||||
sol::function my_func = lua["my_func"];
|
||||
REQUIRE_NOTHROW({
|
||||
auto ent = std::make_shared<Entity>();
|
||||
my_func(ent);
|
||||
Entity ent2;
|
||||
my_func(ent2);
|
||||
my_func(std::make_shared<Entity>());
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user