summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2021-06-21 12:18:06 +0100
committerAlex Orlenko <zxteam@protonmail.com>2021-06-21 12:30:17 +0100
commite4daff8c16aaacb39ed5ca36ca82a58bce442c60 (patch)
tree35b4fccef78f35b890fc2b3ac445e717d55531f9 /tests
parent8d474bbf8d3d6c662921a8c308eb901a6ca422c2 (diff)
downloadmlua-e4daff8c16aaacb39ed5ca36ca82a58bce442c60.zip
Add limited recursion test to increase coverage
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index ea224e7..d3c2d1a 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -847,6 +847,25 @@ fn test_mismatched_registry_key() -> Result<()> {
}
#[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();
let f = lua.create_function(|_, ()| Ok(Variadic::from_iter(1..1000000)))?;