auto-formatting
This commit is contained in:
parent
8a6161b16f
commit
f51a822738
|
@ -51,4 +51,3 @@ macro_rules! lua_assert {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
27
src/tests.rs
27
src/tests.rs
|
@ -22,13 +22,14 @@ fn test_load_debug() {
|
|||
lua.load_debug();
|
||||
}
|
||||
match lua.eval("debug", None).unwrap() {
|
||||
Value::Table(_) => {},
|
||||
val => {
|
||||
panic!("Expected table for debug library, got {:#?}", val)
|
||||
}
|
||||
Value::Table(_) => {}
|
||||
val => panic!("Expected table for debug library, got {:#?}", val),
|
||||
}
|
||||
let traceback_output = lua.eval::<String>("debug.traceback()", None).unwrap();
|
||||
assert_eq!(traceback_output.split("\n").next(), "stack traceback:".into());
|
||||
assert_eq!(
|
||||
traceback_output.split("\n").next(),
|
||||
"stack traceback:".into()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -553,8 +554,16 @@ fn test_pcall_xpcall() {
|
|||
assert!(lua.exec::<()>("xpcall(function() end)", None).is_err());
|
||||
|
||||
// Make sure that the return values from are correct on success
|
||||
assert_eq!(lua.eval::<(bool, String)>("pcall(function(p) return p end, 'foo')", None).unwrap(), (true, "foo".to_owned()));
|
||||
assert_eq!(lua.eval::<(bool, String)>("xpcall(function(p) return p end, print, 'foo')", None).unwrap(), (true, "foo".to_owned()));
|
||||
assert_eq!(
|
||||
lua.eval::<(bool, String)>("pcall(function(p) return p end, 'foo')", None)
|
||||
.unwrap(),
|
||||
(true, "foo".to_owned())
|
||||
);
|
||||
assert_eq!(
|
||||
lua.eval::<(bool, String)>("xpcall(function(p) return p end, print, 'foo')", None)
|
||||
.unwrap(),
|
||||
(true, "foo".to_owned())
|
||||
);
|
||||
|
||||
// Make sure that the return values are correct on errors, and that error handling works
|
||||
|
||||
|
@ -636,7 +645,9 @@ fn test_set_metatable_nil() {
|
|||
r#"
|
||||
a = {}
|
||||
setmetatable(a, nil)
|
||||
"#, None).unwrap();
|
||||
"#,
|
||||
None,
|
||||
).unwrap();
|
||||
}
|
||||
|
||||
// TODO: Need to use compiletest-rs or similar to make sure these don't compile.
|
||||
|
|
|
@ -184,7 +184,8 @@ impl<'lua, T: UserData> UserDataMethods<'lua, T> {
|
|||
R: ToLuaMulti<'lua>,
|
||||
M: 'static + for<'a> FnMut(&'lua Lua, &'a T, A) -> Result<R>,
|
||||
{
|
||||
Box::new(move |lua, mut args| if let Some(front) = args.pop_front() {
|
||||
Box::new(move |lua, mut args| {
|
||||
if let Some(front) = args.pop_front() {
|
||||
let userdata = AnyUserData::from_lua(front, lua)?;
|
||||
let userdata = userdata.borrow::<T>()?;
|
||||
method(lua, &userdata, A::from_lua_multi(args, lua)?)?.to_lua_multi(lua)
|
||||
|
@ -194,6 +195,7 @@ impl<'lua, T: UserData> UserDataMethods<'lua, T> {
|
|||
to: "userdata",
|
||||
message: None,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -203,7 +205,8 @@ impl<'lua, T: UserData> UserDataMethods<'lua, T> {
|
|||
R: ToLuaMulti<'lua>,
|
||||
M: 'static + for<'a> FnMut(&'lua Lua, &'a mut T, A) -> Result<R>,
|
||||
{
|
||||
Box::new(move |lua, mut args| if let Some(front) = args.pop_front() {
|
||||
Box::new(move |lua, mut args| {
|
||||
if let Some(front) = args.pop_front() {
|
||||
let userdata = AnyUserData::from_lua(front, lua)?;
|
||||
let mut userdata = userdata.borrow_mut::<T>()?;
|
||||
method(lua, &mut userdata, A::from_lua_multi(args, lua)?)?.to_lua_multi(lua)
|
||||
|
@ -213,6 +216,7 @@ impl<'lua, T: UserData> UserDataMethods<'lua, T> {
|
|||
to: "userdata",
|
||||
message: None,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue