Module claim

Module claim 

Source
Expand description

Pointwise-claim accumulator API: Verdict, ClaimBuilder, SetClaim, SeqClaim, and the claim! macro.

Verdict is the per-test claim accumulator. Assert holds threshold config and stays Copy; Verdict carries the per-test claim records (which include Vec/String allocations) and is built via Assert::default_checks().verdict() or Verdict::new.

Test authors reach for one of two compile-mechanical labelers:

  1. Typed field accessors generated by #[derive(Claim)] on stats structs — e.g. stats.claim_max_gap_ms(&mut verdict).at_most(100). The label "max_gap_ms" comes from stringify!(max_gap_ms) in the generated method body; renaming the field updates both the method name AND the rendered label.

  2. The claim! macro on a local binding or expression — e.g. claim!(verdict, iter_delta).at_least(100). The label comes from stringify!(<token tree>) over the expression tokens.

There is NO third recommended “manual string” path. The string-taking entry points on Verdict (claim / claim_set / claim_seq / claim_present) are #[doc(hidden)] and expected to be fed only by stringify! via the derive or the claim! macro.

Comparator surface for ClaimBuilder<T>:

  • T: PartialOrd + Display -> at_least / at_most / lt / gt / between
  • T: PartialEq + Display -> eq / ne
  • T = f64 -> is_finite / near

Container claims (set / sequence) bypass scalar comparators and offer empty / nonempty / contains / len_eq / len_at_most / len_at_least / subset_of / disjoint_from instead.

Structs§

ClaimBuilder
Per-claim builder for scalar values. Produced by Verdict::claim (and the typed claim_<field> accessors generated by #[derive(Claim)]). Chain a comparator (at_least, at_most, lt, gt, between, eq, ne, is_finite, near) to record the outcome.
PresentClaim
Per-claim builder for a possibly-absent (Option-valued) metric. Produced by Verdict::claim_present and the claim_present! macro. On Some(v) every comparator delegates to the value-bound ClaimBuilder, so a present metric behaves EXACTLY like claim!. On None the metric is absent — there is nothing to compare, so every comparator records a LOUD Fail (<name>: metric absent) rather than silently passing. This mirrors the no-guessed-value discipline of MetricId::def returning None for an unregistered key: an absent signal fails the gate, it does not vacuously satisfy it (the hazard of metric.unwrap_or(0.0), where a missing metric becomes a sentinel that can pass a bound).
SeqClaim
Per-claim builder for slice / Vec<T> values. Same modifier surface as SetClaim; comparator surface is sequence-specific.
SetClaim
Per-claim builder for BTreeSet<T> values. Same kind / because modifiers as ClaimBuilder; comparator surface is set-specific.
Verdict
Pointwise-claim accumulator.