Skip to content

Commit

Permalink
🛠 Avoid shadowing warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ShepherdSoasis committed Jun 24, 2022
1 parent 3dc3920 commit 150abc4
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ inline namespace sol2_regression_test_1315 {
return a.children;
}

constexpr const auto& code = R"(
} // namespace sol2_regression_test_1315


TEST_CASE("Test for Issue #1315 - memory keep-alive with iteration functions, using a pointer", "[sol2][regression][Issue-1315][pointer]") {
sol::state lua;
lua.open_libraries(sol::lib::base, sol::lib::coroutine);

constexpr const auto& coroutine_iteration_code = R"(
for i=1, 100 do
co = coroutine.create( function()
for child_index, child in ipairs(A.children) do
Expand All @@ -58,21 +65,14 @@ end)
coroutine.resume(co)
end)";

} // namespace sol2_regression_test_1315


TEST_CASE("Test for Issue #1315 - memory keep-alive with iteration functions, using a pointer", "[sol2][regression][Issue-1315][pointer]") {
sol::state lua;
lua.open_libraries(sol::lib::base, sol::lib::coroutine);

A a {};
for (int i = 0; i < 100; i++) {
a.children.push_back(i);
}

auto perform_action = [&lua]() {
// call lua code directly
auto result = lua.safe_script(code, sol::script_pass_on_error);
auto result = lua.safe_script(coroutine_iteration_code, sol::script_pass_on_error);
sol::optional<sol::error> maybe_err = result.get<sol::optional<sol::error>>();
REQUIRE(result.status() == sol::call_status::ok);
REQUIRE_FALSE(maybe_err.has_value());
Expand Down

0 comments on commit 150abc4

Please sign in to comment.