"game_core/git@weirdboi.dev:microhacks/trader-tales.git" did not exist on "419ff09b479610953e5a3b7d1540cbce9b155ead"
Newer
Older

Louis
committed
use forge_script_lang::parse::{parse_expression, parse_program};
use std::path::PathBuf;
fn get_base_path() -> Result<PathBuf, std::io::Error> {
let mut cwd = std::env::current_dir()?;
let mut path = PathBuf::from(file!());
cwd.pop();
path.pop();
path.push("cases");
Ok(cwd.join(path))
}
fn iterate_files() -> Result<Vec<PathBuf>, std::io::Error> {
let base = get_base_path()?;
let mut files = Vec::with_capacity(10);
for file in std::fs::read_dir(base.display().to_string())? {
let entry = file?;
files.push(entry.path());
}
Ok(files)
}
fn read_and_parse(path: PathBuf) -> Result<(), std::io::Error> {
let file = std::fs::read_to_string(path)?;
parse_program(file.as_str()).expect("Failed to parse");
Ok(())
}
#[test]
fn parse_all_programs() -> Result<(), std::io::Error> {
for file in iterate_files()?.into_iter() {
read_and_parse(file)?;
}
Ok(())
}