From 26b7901ab35b7094ef8e3dfe623045f2670aa686 Mon Sep 17 00:00:00 2001 From: Timidger Date: Sun, 29 Oct 2017 14:53:30 -0700 Subject: [PATCH] Added test for loading unsafe debug library in Lua --- src/tests.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/tests.rs b/src/tests.rs index 327d997..028f0be 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -14,6 +14,23 @@ fn test_load() { assert!(lua.load("§$%§&$%&", None).is_err()); } +#[test] +fn test_load_debug() { + let lua = Lua::new(); + lua.eval::<()>("debug", None).unwrap(); + unsafe { + lua.load_debug(); + } + match lua.eval("debug", None).unwrap() { + Value::Table(_) => {}, + val => { + panic!("Expected table for debug library, got {:#?}", val) + } + } + let traceback_output = lua.eval::("debug.traceback()", None).unwrap(); + assert_eq!(traceback_output.split("\n").next(), "stack traceback:".into()); +} + #[test] fn test_exec() { let lua = Lua::new();