test(domain): R5.7 port the contracts only the TS suites checked
612 leaves and 26 legacy ids (curation_leaves), region inference, R5.1 ledger rows, generated folder lists, migration-map oracle entry by entry, overlay removal, halo filter, CHG-000 and dollar-tag refusals; report-v2 fixtures moved to crates/core/tests (sha256 unchanged).
This commit is contained in:
1 parent
756b7ef34d
commit
0da7d3ab9f
11 files changed
+634
-11
No files matched your search
@@ -10,6 +10,7 @@ mod common;
|
||||
use faunosteo_core::anatomy::svg::number::{is_js_space, js_number_of, js_split_list};
|
||||
use faunosteo_core::curation::PipelineError;
|
||||
use faunosteo_core::curation::ids::deterministic_uuid;
|
||||
use faunosteo_core::curation::legacy::regions::{RegionMatch, infer_region_code};
|
||||
use faunosteo_core::curation::markdown::format_markdown;
|
||||
use faunosteo_core::curation::prettier_json::format_json;
|
||||
use faunosteo_core::curation::text::{js_keys, js_round, slugify};
|
||||
@@ -187,3 +188,66 @@ fn js_string(value: f64) -> String {
|
||||
js_number(value)
|
||||
}
|
||||
}
|
||||
|
||||
fn region(fr: Option<&str>, en: Option<&str>) -> Option<String> {
|
||||
infer_region_code(fr, en).map(|m| m.code)
|
||||
}
|
||||
|
||||
/// `inferRegionCode` as Node ran it (`js-semantics.json`, 12 rows: root, label and code) and the
|
||||
/// cases of the deleted `legacy.regions.test.ts` (R5.7): FR roots with and without accents, EN
|
||||
/// roots when FR is absent, FR before EN, the EN fallback when FR names no root.
|
||||
#[test]
|
||||
fn region_inference_follows_the_typescript() {
|
||||
let semantics = oracle("js-semantics.json");
|
||||
let cases = rows(&semantics, "inferRegionCode");
|
||||
assert_eq!(cases.len(), 12);
|
||||
for case in cases {
|
||||
let (fr, en) = (case["fr"].as_str(), case["en"].as_str());
|
||||
let actual = infer_region_code(fr, en).map(|RegionMatch { code, root, label }| {
|
||||
serde_json::json!({ "code": code, "root": root, "label": label })
|
||||
});
|
||||
assert_eq!(
|
||||
actual.unwrap_or(Value::Null),
|
||||
case["match"],
|
||||
"{fr:?} / {en:?}"
|
||||
);
|
||||
}
|
||||
for (fr, code) in [
|
||||
("Vertèbres cervicales", "C"),
|
||||
("Vertebres cervicales", "C"),
|
||||
("Vertèbres thoraciques", "T"),
|
||||
("Vertebres thoraciques", "T"),
|
||||
("Vertèbres lombaires", "L"),
|
||||
("Vertèbres sacrales", "S"),
|
||||
("Vertèbres sacrées", "S"),
|
||||
("Vertèbres caudales", "Cd"),
|
||||
("Vertèbres coccygiennes", "Cd"),
|
||||
("Région dorsale", "T"),
|
||||
] {
|
||||
assert_eq!(region(Some(fr), None).as_deref(), Some(code), "{fr}");
|
||||
}
|
||||
for (en, code) in [
|
||||
("Cervical Vertebrae", "C"),
|
||||
("Thoracic Vertebrae", "T"),
|
||||
("Lumbar Vertebrae", "L"),
|
||||
("Sacral Vertebrae", "S"),
|
||||
("Coccygeal Vertebrae", "Cd"),
|
||||
] {
|
||||
assert_eq!(region(None, Some(en)).as_deref(), Some(code), "{en}");
|
||||
}
|
||||
assert_eq!(region(Some("Épaule"), Some("Shoulder")), None);
|
||||
assert_eq!(region(Some(""), Some("")), None);
|
||||
assert_eq!(region(None, None), None);
|
||||
assert_eq!(
|
||||
infer_region_code(Some("Vertèbres lombaires"), Some("Cervical")),
|
||||
Some(RegionMatch {
|
||||
code: "L".into(),
|
||||
root: "lombair".into(),
|
||||
label: "Vertèbres lombaires".into()
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
region(Some("Épaule"), Some("Cervical Vertebrae")).as_deref(),
|
||||
Some("C")
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user