@@ -190,29 +190,42 @@ TEST_F(StackTests, BoolStackOverflow)
190190
191191TEST_F (StackTests, BoolInvalidType)
192192{
193- // Non-boolean types are rejected even in non-strict mode
193+ #if !LUABRIDGE_STRICT_STACK_CONVERSIONS
194+ // Non-strict mode: any Lua value is accepted via lua_toboolean
194195 {
195196 (void )luabridge::Stack<int >::push (L, 0 );
196197 auto result = luabridge::Stack<bool >::get (L, -1 );
197- ASSERT_FALSE (result);
198+ ASSERT_TRUE (result);
199+ EXPECT_TRUE (*result); // integer 0 is truthy in Lua
198200 }
199201
200202 {
201203 (void )luabridge::Stack<int >::push (L, 42 );
202204 auto result = luabridge::Stack<bool >::get (L, -1 );
203- ASSERT_FALSE (result);
205+ ASSERT_TRUE (result);
206+ EXPECT_TRUE (*result);
204207 }
205208
206- #if !LUABRIDGE_STRICT_STACK_CONVERSIONS
207- // nil converts to false in non-strict mode
208209 {
209210 (void )luabridge::Stack<std::nullptr_t >::push (L, nullptr );
210211 auto result = luabridge::Stack<bool >::get (L, -1 );
211212 ASSERT_TRUE (result);
212- EXPECT_FALSE (*result);
213+ EXPECT_FALSE (*result); // nil is falsy
213214 }
214215#else
215- // nil is rejected in strict mode
216+ // Strict mode: only LUA_TBOOLEAN is accepted
217+ {
218+ (void )luabridge::Stack<int >::push (L, 0 );
219+ auto result = luabridge::Stack<bool >::get (L, -1 );
220+ ASSERT_FALSE (result);
221+ }
222+
223+ {
224+ (void )luabridge::Stack<int >::push (L, 42 );
225+ auto result = luabridge::Stack<bool >::get (L, -1 );
226+ ASSERT_FALSE (result);
227+ }
228+
216229 {
217230 (void )luabridge::Stack<std::nullptr_t >::push (L, nullptr );
218231 auto result = luabridge::Stack<bool >::get (L, -1 );
0 commit comments