summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2021-06-13 22:38:51 +0100
committerAlex Orlenko <zxteam@protonmail.com>2021-06-13 22:38:51 +0100
commit08ffeb0ca92f84b54b74c7f4d78a4387770c257b (patch)
tree69455fcc1bbdb3d95e934b45276182ca025bc4f2 /tests
parent3b9d8a7b5f521e80683fc5b54a039b609c4b5b8c (diff)
downloadmlua-08ffeb0ca92f84b54b74c7f4d78a4387770c257b.zip
Improve module mode:
- Don't hide module function inside `luaopen_%` function. - Raise Lua exception instead of panic if module function returns error.
Diffstat (limited to 'tests')
-rw-r--r--tests/module/tests/load.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/module/tests/load.rs b/tests/module/tests/load.rs
index 5acad79..83a9cf8 100644
--- a/tests/module/tests/load.rs
+++ b/tests/module/tests/load.rs
@@ -28,6 +28,19 @@ fn test_module_multi() -> Result<()> {
.exec()
}
+#[test]
+fn test_module_error() -> Result<()> {
+ let lua = make_lua()?;
+ lua.load(
+ r#"
+ local ok, err = pcall(require, "rust_module.error")
+ assert(not ok)
+ assert(string:find(tostring(err), "custom module error"))
+ "#,
+ )
+ .exec()
+}
+
#[cfg(any(
feature = "lua54",
feature = "lua53",