From c784bfe1d4c98ab3f8aa533cc6ecd8e160addb79 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Sun, 8 Nov 2026 22:34:51 -0700 Subject: [PATCH] test(core): the gate's call and field probes The stricter call matcher and the field check were fixed in code but had no self-test, so a regression could hide behind the gate's own pass. These probe them directly: x.take(5), a bare mention and other::take( are not calls, kernel::take( is; Iif::form_4797 and TaxSummary::changes are the other type's items and must not resolve, while each type's own fields and methods do. The made-up-name probe also gains NaiveDate::NoSuchThing and the two bogus prefixes, and the `tests` probe now says plainly that bare `tests` resolves as a Rust item (`mod tests`), not as a crate. Co-Authored-By: DeepSeek V4.1 Flash --- .../tests/bookspec/traceability.rs | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/crates/ledger-core/tests/bookspec/traceability.rs b/crates/ledger-core/tests/bookspec/traceability.rs index b2b71b48..a3ba16fc 100644 --- a/crates/ledger-core/tests/bookspec/traceability.rs +++ b/crates/ledger-core/tests/bookspec/traceability.rs @@ -2563,6 +2563,54 @@ fn made_up_names_do_not_resolve() { ); } +/// `calls` finds a call, never a mention: a method call, a bare mention, or +/// another module's function of the same name is not the kernel's call. +#[test] +fn calls_finds_a_call_not_a_mention() { + assert!( + !calls("x.take(5)", "take"), + "a method call is not the kernel's" + ); + assert!(!calls("take", "take"), "a bare mention is not a call"); + assert!( + !calls("other::take(5)", "take"), + "another module's take is not the kernel's" + ); + assert!(calls("kernel::take(5)", "take"), "a kernel call counts"); + assert!(calls("take(5)", "take"), "an imported bare call counts"); + assert!(calls("kernel::Direction::flip(d)", "Direction::flip")); + assert!( + !calls("kernel::Direction::flip(d)", "flip"), + "a type's flip is not the free flip" + ); +} + +/// A field belongs to its own type, and a method to its own type: a field +/// of `Iif` never backs `TaxSummary::…`, nor the reverse. +#[test] +fn a_field_belongs_to_its_own_type() { + let root = repo_root(); + let (defs, bases, all_paths) = main_index(&root); + for token in [ + "Iif::changes", + "Iif::receivable_payable", + "Iif::warnings", + "TaxSummary::form_4797", + ] { + assert_eq!( + resolve(token, &defs, &bases, &all_paths), + Ok(Class::RustItem), + "`{token}` is a real item of its type" + ); + } + for token in ["Iif::form_4797", "TaxSummary::changes"] { + assert!( + resolve(token, &defs, &bases, &all_paths).is_err(), + "`{token}` is a field of the other type and must not resolve" + ); + } +} + #[test] fn a_harness_listed_twice_must_agree() { let mut laws = BTreeMap::new();