From bf032e6ce403081282a968d5baae7397469d9aea Mon Sep 17 00:00:00 2001 From: Akulij Date: Sun, 18 May 2025 16:07:40 +0300 Subject: [PATCH] create test for deserealization of mainbot.js --- src/botscript.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/botscript.rs b/src/botscript.rs index 980a2ea..89bb9ca 100644 --- a/src/botscript.rs +++ b/src/botscript.rs @@ -77,6 +77,16 @@ mod tests { println!("Val: {:?}", val.to_string()); } + #[test] + fn test_deserialization_main() { + let runner = Runner::init().unwrap(); + let val = runner.run_script(include_str!("../mainbot.js")).unwrap(); + let s: RunnerConfig = from_js(unsafe { runner.context.context_raw() }, &val).unwrap(); + println!("deser: {:#?}", s); + let o = val.try_into_object().unwrap(); + println!("o: {:?}", recursive_format(o)); + } + fn recursive_format(o: OwnedJsObject) -> String { let props: Vec<_> = o.properties_iter().unwrap().map(|x| x.unwrap()).collect(); let sp: Vec = props