summaryrefslogtreecommitdiff
path: root/tests/luau.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2024-01-27 11:51:59 +0000
committerAlex Orlenko <zxteam@protonmail.com>2024-01-27 11:51:59 +0000
commite30b42522433b31523eb929c1ac37bfbaf07ebfc (patch)
treefff31923a831b1c1ddaa5492ec181800f5bba66b /tests/luau.rs
parent512921404c7942e7c8a31bcafee7b264681b6007 (diff)
downloadmlua-e30b42522433b31523eb929c1ac37bfbaf07ebfc.zip
Fix crash when initializing Luau sandbox without stdlibs (#361)
Diffstat (limited to 'tests/luau.rs')
-rw-r--r--tests/luau.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/luau.rs b/tests/luau.rs
index 987ea4f..aedcc53 100644
--- a/tests/luau.rs
+++ b/tests/luau.rs
@@ -276,6 +276,22 @@ fn test_sandbox() -> Result<()> {
}
#[test]
+fn test_sandbox_nolibs() -> Result<()> {
+ let lua = Lua::new_with(StdLib::NONE, LuaOptions::default()).unwrap();
+
+ lua.sandbox(true)?;
+ lua.load("global = 123").exec()?;
+ let n: i32 = lua.load("return global").eval()?;
+ assert_eq!(n, 123);
+ assert_eq!(lua.globals().get::<_, Option<i32>>("global")?, Some(123));
+
+ lua.sandbox(false)?;
+ assert_eq!(lua.globals().get::<_, Option<i32>>("global")?, None);
+
+ Ok(())
+}
+
+#[test]
fn test_sandbox_threads() -> Result<()> {
let lua = Lua::new();