diff options
author | nat-goodspeed <nat@lindenlab.com> | 2024-07-01 10:50:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-01 10:50:15 -0400 |
commit | 14a05ec7ac2e2df5886e4dc7ae33ce57a4272b8d (patch) | |
tree | 580c3c2cbc195d888911e5ce1c5822e589de2db3 /indra/newview/tests | |
parent | 75accbefdbe7741d57bf093690d65ad1100f82d4 (diff) | |
parent | cfd7d8905d686411a774c47bbfc13f49882b65e6 (diff) |
Merge pull request #1871 from secondlife/lua_emplace_better
Streamline and robustify lua_emplace<T>() object cleanup.
Diffstat (limited to 'indra/newview/tests')
-rw-r--r-- | indra/newview/tests/llluamanager_test.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/indra/newview/tests/llluamanager_test.cpp b/indra/newview/tests/llluamanager_test.cpp index 2d525f7913..d3fc70dfd5 100644 --- a/indra/newview/tests/llluamanager_test.cpp +++ b/indra/newview/tests/llluamanager_test.cpp @@ -465,4 +465,39 @@ namespace tut ensure_equals(desc + " count: " + result.asString(), count, -1); ensure_contains(desc + " result", result.asString(), "terminated"); } + + template <typename T> + struct Visible + { + Visible(T name): name(name) + { + LL_INFOS() << "Visible<" << LLError::Log::classname<T>() << ">('" << name << "')" << LL_ENDL; + } + Visible(const Visible&) = delete; + Visible& operator=(const Visible&) = delete; + ~Visible() + { + LL_INFOS() << "~Visible<" << LLError::Log::classname<T>() << ">('" << name << "')" << LL_ENDL; + } + T name; + }; + + template<> template<> + void object::test<9>() + { + set_test_name("track distinct lua_emplace<T>() types"); + LuaState L; + lua_emplace<Visible<std::string>>(L, "std::string 0"); + int st0tag = lua_userdatatag(L, -1); + lua_emplace<Visible<const char*>>(L, "const char* 0"); + int cp0tag = lua_userdatatag(L, -1); + lua_emplace<Visible<std::string>>(L, "std::string 1"); + int st1tag = lua_userdatatag(L, -1); + lua_emplace<Visible<const char*>>(L, "const char* 1"); + int cp1tag = lua_userdatatag(L, -1); + lua_settop(L, 0); + ensure_equals("lua_emplace<std::string>() tags diverge", st0tag, st1tag); + ensure_equals("lua_emplace<const char*>() tags diverge", cp0tag, cp1tag); + ensure_not_equals("lua_emplace<>() tags collide", st0tag, cp0tag); + } } // namespace tut |