openquest/openquest-lib/tests/syntax/mod.rs

42 lines
1.2 KiB
Rust

// Standard Uses
use std::fs;
// Local Uses
// External Uses
use openquest_lib::syntax::legacy::v1_0_0::parser;
use openquest_lib::inter_repr::Unit;
#[test]
fn parse_script_simple() {
let script = fs::read_to_string("tests/data/simple.quest").unwrap();
let units = parser::parse_into_unit(script.as_str()).unwrap();
assert_eq!(units, vec![
Unit::Quest {
name: "test".to_string(), states: vec![
Unit::State {
name: "simple".to_string(),
whens: vec![
Unit::When {
condition: "trigger".to_string(),
with: "".to_string(),
body: Box::new(Unit::LuaScope("trigger_some()".to_string())),
}
],
functions: vec![
Unit::Function {
name: "trigger_some".to_string(),
arguments: "".to_string(),
body: Box::new(Unit::LuaScope("print(\"hello\")".to_string())),
}
],
}
]
},
])
}