From 4c5d11823802175cfaf083a6fcd20a3006b27d51 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Fri, 18 Apr 2025 17:53:27 +0200 Subject: A unit test for linda wake_period --- src/linda.cpp | 10 +++++++++- src/macros_and_utils.hpp | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/linda.cpp b/src/linda.cpp index a9ae61c..fa28385 100644 --- a/src/linda.cpp +++ b/src/linda.cpp @@ -1178,7 +1178,15 @@ LUAG_FUNC(linda) if (lua_isnil(L_, kIdxTop)) { lua_pop(L_, 1); lua_pushnumber(L_, _U->lindaWakePeriod.count()); - } else { + } else if (luaG_type(L_, kIdxTop) == LuaType::STRING) { + if (luaG_tostring(L_, kIdxTop) != "never") { + luaL_argerror(L_, 1, "invalid wake_period"); + } else { + lua_pop(L_, 1); + lua_pushnumber(L_, 0); + } + } + else { luaL_argcheck(L_, luaL_optnumber(L_, 2, 0) > 0, 1, "wake_period must be > 0"); } diff --git a/src/macros_and_utils.hpp b/src/macros_and_utils.hpp index 16011f7..1aca818 100644 --- a/src/macros_and_utils.hpp +++ b/src/macros_and_utils.hpp @@ -21,6 +21,7 @@ inline void STACK_GROW(lua_State* const L_, int const n_) // ################################################################################################# +// 1 unit of lua_Duration lasts 1 second (using default period of std::ratio<1>) using lua_Duration = std::chrono::template duration; // ################################################################################################# -- cgit v1.2.3-55-g6feb