bookspec split the CHOICEs embedded in BS-partner-1..4, BS-asset-1, BS-asset-4, BS-1099-1 and BS-format-2 into records of their own (S-C7b). Wanderbooks' decisions are unchanged; each is now recorded against the id an engine declares it by: - partner: BS-partner-5 largest-remainder-first-listed (owner, 2026-10-13), -6 cumulative-from-first-close (D-10, 2026-10-16), -7 running-split (D-38, 2026-10-20), -8 outside-the-books and -9 tin-facts-then-w9 (2026-10-15), -10..-13 money, entry flow, books' carrying amount, labelled basis (2026-10-15, 2026-10-20), -14 tax-basis-beside-book (D-41), -15 running-cumulative (D-38's rule, 2026-10-22) - asset: BS-asset-5 straight-line-by-days, -6 lesser-of-value-and-basis, -7 books-recorded-amounts, -8 register-carries-tax-figures - 1099: BS-1099-2 refuse-an-unknown-year, -3 presumed-a-check-ach-or-transfer, -4 dated-by-the-payments-date - format: BS-format-3..7 (D-36, 2026-10-20) Each is a `**Pick (BS-..):**` line in docs/spec/claims/<area>.md and a `with_choice` in the adapter's claims(). The rules_md test no longer expects a B-n row for a rule born without one (a split-out CHOICE has none): it requires the pick line, that the pick is one of the record's options, and that the adapter declares the same option. The pin is not moved here: this needs bookspec's s-c7b to be merged and the pin moved to it. Verified with ledger-core's bookspec test patched to the s-c7b checker and runner (53 passed). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
74 lines
2.9 KiB
Rust
74 lines
2.9 KiB
Rust
use crate::*;
|
|
|
|
/// `docs/spec/claims/*.md` carry every stated rule's id under its heading,
|
|
/// `docs/spec/rules.md` indexes every rule to its claims file, and neither
|
|
/// calls a choice a decision (P14 unit S-D0; P13 step 3).
|
|
#[test]
|
|
pub(crate) fn rules_md_carries_every_id() {
|
|
let spec = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../docs/spec");
|
|
let index = std::fs::read_to_string(spec.join("rules.md")).expect("docs/spec/rules.md");
|
|
|
|
let mut claims = std::fs::read_dir(spec.join("claims"))
|
|
.expect("docs/spec/claims")
|
|
.map(|entry| entry.expect("a claims entry").path())
|
|
.filter(|path| path.extension().is_some_and(|ext| ext == "md"))
|
|
.collect::<Vec<_>>();
|
|
claims.sort();
|
|
assert!(!claims.is_empty(), "docs/spec/claims holds the rule text");
|
|
|
|
let mut all = String::new();
|
|
for path in &claims {
|
|
let text = std::fs::read_to_string(path)
|
|
.unwrap_or_else(|error| panic!("{}: {error}", path.display()));
|
|
all.push_str(&text);
|
|
all.push('\n');
|
|
}
|
|
|
|
for rule in bookspec_checker::rules().iter() {
|
|
if rule.b == 0 {
|
|
// A rule born after the B numbering has no row in the index.
|
|
// A CHOICE record split out of another rule (P14 unit S-C7)
|
|
// has its pick recorded in its claims file, and the engine's
|
|
// adapter declares the same option, which the record names.
|
|
if rule.status == Some(bookspec_checker::Status::Choice) {
|
|
let marker = format!("**Pick ({}):** `", rule.id);
|
|
let at = all
|
|
.find(&marker)
|
|
.unwrap_or_else(|| panic!("{} carries its pick in its claims file", rule.id));
|
|
let option = all[at + marker.len()..].split('`').next().unwrap();
|
|
assert!(
|
|
rule.record().options.iter().any(|o| o.name == option),
|
|
"{}'s pick {option:?} is one of its options",
|
|
rule.id
|
|
);
|
|
assert!(
|
|
engine::PICKS_S_C7B
|
|
.iter()
|
|
.any(|&(area, n, o)| RuleId::new(area, n) == rule.id && o == option),
|
|
"{}'s pick {option:?} is declared in the adapter's claims()",
|
|
rule.id
|
|
);
|
|
}
|
|
continue;
|
|
}
|
|
assert!(
|
|
index.contains(&format!("| B-{} | `{}` |", rule.b, rule.id)),
|
|
"rules.md indexes B-{} to {}",
|
|
rule.b,
|
|
rule.id
|
|
);
|
|
if rule.status.is_some() {
|
|
assert!(
|
|
all.contains(&format!("**bookspec:** `{}`", rule.id)),
|
|
"B-{} carries {} in its claims file",
|
|
rule.b,
|
|
rule.id
|
|
);
|
|
}
|
|
}
|
|
assert!(
|
|
!index.contains("DECISION") && !all.contains("DECISION"),
|
|
"the rules speak bookspec's CHOICE"
|
|
);
|
|
}
|