setmetatable should return the table
This commit is contained in:
parent
9c34d4b99f
commit
c3c7d8c093
16
src/tests.rs
16
src/tests.rs
|
@ -904,19 +904,31 @@ fn test_pcall_xpcall() {
|
|||
|
||||
xpcall_error = nil
|
||||
xpcall(error, function(err) xpcall_error = err end, "testerror")
|
||||
|
||||
function xpcall_recursion()
|
||||
xpcall(error, function(err) error(err) end, "testerror")
|
||||
end
|
||||
"#,
|
||||
None,
|
||||
).unwrap();
|
||||
|
||||
let globals = lua.globals();
|
||||
|
||||
assert_eq!(
|
||||
lua.globals().get::<_, String>("pcall_error").unwrap(),
|
||||
globals.get::<_, String>("pcall_error").unwrap(),
|
||||
"testerror"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
lua.globals().get::<_, String>("xpcall_error").unwrap(),
|
||||
globals.get::<_, String>("xpcall_error").unwrap(),
|
||||
"testerror"
|
||||
);
|
||||
|
||||
// Make sure that weird xpcall error recursion at least doesn't cause unsafety or panics.
|
||||
let _ = globals
|
||||
.get::<_, Function>("xpcall_recursion")
|
||||
.unwrap()
|
||||
.call::<_, ()>(());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -520,7 +520,7 @@ pub unsafe extern "C" fn safe_setmetatable(state: *mut ffi::lua_State) -> c_int
|
|||
ffi::lua_pop(state, 1);
|
||||
}
|
||||
ffi::lua_setmetatable(state, -2);
|
||||
0
|
||||
1
|
||||
}
|
||||
|
||||
// Does not call checkstack, uses 1 stack space
|
||||
|
|
Loading…
Reference in New Issue