From e4daff8c16aaacb39ed5ca36ca82a58bce442c60 Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Mon, 21 Jun 2021 12:18:06 +0100 Subject: [PATCH] Add limited recursion test to increase coverage --- tests/tests.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/tests.rs b/tests/tests.rs index ea224e7..d3c2d1a 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -846,6 +846,25 @@ fn test_mismatched_registry_key() -> Result<()> { Ok(()) } +#[test] +fn test_recursion() -> Result<()> { + let lua = Lua::new(); + + let f = lua.create_function(move |lua, i: i32| { + if i < 64 { + lua.globals() + .get::<_, Function>("f")? + .call::<_, ()>(i + 1)?; + } + Ok(()) + })?; + + lua.globals().set("f", f.clone())?; + f.call::<_, ()>(1)?; + + Ok(()) +} + #[test] fn test_too_many_returns() -> Result<()> { let lua = Lua::new();