make initial implementation
credit - https://github.com/AlphaModder/include-lua
This commit is contained in:
26
tests/tests.rs
Normal file
26
tests/tests.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use rlua::Lua;
|
||||
use rlua_searcher::{AddSearcher, Result};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let lume = read_lume_to_string();
|
||||
let name = "lume".to_string();
|
||||
let mut map = HashMap::new();
|
||||
map.insert(name, lume);
|
||||
|
||||
let lua = Lua::new();
|
||||
|
||||
let hello = lua
|
||||
.context::<_, Result<String>>(|lua_ctx| {
|
||||
lua_ctx.add_searcher(map)?;
|
||||
Ok(lua_ctx.load(r#"return require("lume")"#).eval()?)
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
assert_eq!("hello lume", hello);
|
||||
}
|
||||
|
||||
fn read_lume_to_string() -> String {
|
||||
r#"return "hello lume""#.to_string()
|
||||
}
|
Reference in New Issue
Block a user