//! Scene carriage (`extensions/scene-carriage.md`): the committed corpus regenerates byte for //! byte (every export written, every import read back to its bundle or refused as stated), and //! the extension's §8 lists the codes the reference reports. use std::collections::BTreeMap; use std::path::{Path, PathBuf}; use wai::scene_map::{corpus, CODES}; fn root() -> PathBuf { Path::new(env!("CARGO_MANIFEST_DIR")).join("../live-conformance/scene") } fn walk(root: &Path, rel: &str, out: &mut BTreeMap>) { for e in std::fs::read_dir(root.join(rel)).unwrap().flatten() { let name = e.file_name().to_string_lossy().into_owned(); let key = if rel.is_empty() { name } else { format!("{rel}/{name}") }; if e.path().is_dir() { walk(root, &key, out); } else if key != "README.md" && key != ".gitattributes" { out.insert(key, std::fs::read(e.path()).unwrap()); } } } #[test] fn the_committed_corpus_regenerates_byte_for_byte() { let mut files = BTreeMap::new(); walk(&root(), "", &mut files); let inputs: BTreeMap> = corpus::INPUT_FILES.iter().map(|(p, _)| (p.to_string(), std::fs::read(root().join(p)).unwrap())).collect(); let bad = corpus::verify(&files, &inputs); assert!(bad.is_empty(), "{bad:#?}"); } #[test] fn the_extension_lists_every_code_the_reference_reports() { let text = std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join("../extensions/scene-carriage.md")).unwrap(); let sec = text.split("\n## 8.").nth(1).expect("§8").split("\n## ").next().unwrap(); let listed: Vec<&str> = sec.lines().filter_map(|l| l.strip_prefix("| `")).filter_map(|l| l.split('`').next()).collect(); assert_eq!(listed, CODES, "§8's table, in order"); }