use std::collections::HashMap; use temple::Context; #[test] fn check_cases() { insta::glob!("cases/*.temple", |path| { let mut settings = insta::Settings::clone_current(); settings.set_snapshot_path("cases"); settings.set_snapshot_suffix(path.file_stem().unwrap().display().to_string()); settings.set_prepend_module_to_snapshot(false); let _guard = settings.bind_to_scope(); let input = std::fs::read_to_string(path).unwrap(); let (context, input) = input.split_once("\n---\n").unwrap_or_else(|| ("", &input)); let map = if !context.is_empty() { serde_json::from_str::>(context).unwrap() } else { HashMap::new() }; let mut context = Context::new(); for (k, v) in map { context.insert(k, v); } let parsed = temple::parser::parse(input.into()).unwrap(); insta::assert_debug_snapshot!("1-parsed", parsed); let ast = temple::ast::parse(parsed.tokens()).unwrap(); insta::assert_debug_snapshot!("2-ast", ast); let emit = temple::emit::emit_machine(ast); insta::assert_debug_snapshot!("3-instructions", emit); let output = temple::eval::execute(&emit, &context).unwrap(); insta::assert_debug_snapshot!("4-output", output); }); }