test(core): the adapter runs drafts and evidence
bookspec's examples for BS-entry-5, BS-entry-6 and BS-ledger-17 are run through the real Store, none reimplemented: a draft is made by `Store::create_entry` and `add_line` (tried on a clone first, so a line the engine refuses on a header account leaves no half-made draft in the journal), posted by `post_entry_checked` when the example states an evidence policy (the server's gate; the primitive otherwise), given its state by `set_draft_state`, its document by `attach_receipt` and thrown away by `discard_draft`. A close a draft holds back is tried on a clone too. The two queries are read off the engine: a draft's state from the entry itself, and the evidence decision from `evidence::requirement`, its sentence of exemption read into the examples' closed words. The refusals are read off the engine's errors: a placeholder account is `header_account`, the receipt gate `evidence_required`, a draft's command on an entry that is no draft `not_drafted`, a close with a draft in its period `drafts_in_period`. Wanderbooks passes every example for its picks (check-when-line-added, reversal-evidence-is-originals); the two examples for the other options are skipped, so the pinned skip count goes from 11 to 13. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
609e4e6b26
commit
8c57046c53
10 files changed
+378
-32
No files matched your search
@@ -163,6 +163,17 @@ pub(crate) fn refusal(e: &LedgerError) -> String {
|
||||
LedgerError::ParentTypeMismatch { .. } => "parent_type_mismatch",
|
||||
LedgerError::EntryAlreadyReversed(..) => "already_reversed",
|
||||
LedgerError::ClosedPeriod(..) => "period_closed",
|
||||
// A line on a header account (a placeholder takes no postings),
|
||||
// BS-entry-1 and BS-entry-6.
|
||||
LedgerError::PlaceholderAccount(_) => "header_account",
|
||||
// A close with a draft dated in its period (BS-period-2).
|
||||
LedgerError::DraftsInPeriod(_) => "drafts_in_period",
|
||||
// A draft's command on an entry that is no draft: it is posted
|
||||
// already (a post, a state, a discard), or was discarded and is
|
||||
// gone (BS-entry-5).
|
||||
LedgerError::EntryAlreadyPosted(_)
|
||||
| LedgerError::PostedEntryImmutable
|
||||
| LedgerError::UnknownEntry(_) => "not_drafted",
|
||||
other => return format!("another refusal: {other}"),
|
||||
}
|
||||
.to_string()
|
||||
@@ -173,6 +184,8 @@ pub(crate) fn refusal(e: &LedgerError) -> String {
|
||||
pub(crate) fn store_refusal(e: &StoreError) -> String {
|
||||
match e {
|
||||
StoreError::Ledger(e) => refusal(e),
|
||||
// The evidence gate (BS-entry-5): the entry needs a document.
|
||||
StoreError::ReceiptRequired(_) => "evidence_required".to_string(),
|
||||
other => format!("another refusal: {other}"),
|
||||
}
|
||||
}
|
||||
@@ -210,6 +223,7 @@ pub(crate) fn exact(s: &str, what: &str) -> Decimal {
|
||||
pub(crate) fn store_refusal_obj(e: &StoreError) -> Refusal {
|
||||
match e {
|
||||
StoreError::Ledger(e) => Refusal::of_reason(refusal(e)),
|
||||
StoreError::ReceiptRequired(_) => Refusal::of_reason("evidence_required"),
|
||||
other => Refusal::of_reason(format!("another refusal: {other}")),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user