Refactor and overhaul luajit crate
This commit is contained in:
@@ -26,7 +26,7 @@ end
|
||||
|
||||
local function create_test(name, f, group)
|
||||
local test = { type = "test", name = name or "", group = group, state = "pending", f = f }
|
||||
local fenv = setmetatable({}, { __index = global })
|
||||
local fenv = setmetatable({}, { __index = global, __newindex = global })
|
||||
setfenv(f, fenv)
|
||||
return test
|
||||
end
|
||||
@@ -45,7 +45,7 @@ local function create_group(name, f, parent)
|
||||
table.insert(group.items, item)
|
||||
return item
|
||||
end,
|
||||
}, { __index = global })
|
||||
}, { __index = global, __newindex = global })
|
||||
|
||||
setfenv(f, fenv)
|
||||
f(group)
|
||||
|
||||
@@ -10,14 +10,17 @@ fn main() -> ExitCode {
|
||||
let lua = {
|
||||
let mut rt = lb::runtime::Builder::new();
|
||||
luby::open(&mut rt);
|
||||
rt.unhandled_error(error_cb).build().unwrap()
|
||||
rt.unhandled_error(error_cb)
|
||||
.prohibit_globals(true)
|
||||
.build()
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
let path = "tests/main.lua";
|
||||
let main = lua.spawn(async move |s| {
|
||||
if let Err(ref err) = s.load(Chunk::new(fs::read(path).unwrap()).path(path)) {
|
||||
if let Err(ref err) = s.load(&Chunk::new(fs::read(path).unwrap()).with_path(path)) {
|
||||
s.report_error(err);
|
||||
} else if let Err(ref err) = s.call_async(0, 1).await {
|
||||
} else if let Err(ref err) = s.call_async(0, Some(1)).await {
|
||||
s.report_error(err);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user