pub enum Eval {
Boolean {
criterion: String,
expected: bool,
name: Option<String>,
},
Numeric {
criterion: String,
min: f64,
max: f64,
threshold: f64,
comparator: Comparator,
name: Option<String>,
},
Called {
mock: String,
times: Option<u64>,
where: BTreeMap<String, FieldPredicate>,
name: Option<String>,
},
NotCalled {
mock: String,
where: BTreeMap<String, FieldPredicate>,
name: Option<String>,
},
}Expand description
An eval specification, as written in a test case’s YAML.
Variants§
Boolean
Assert a plain-English criterion holds (or, with expected: false, that
it does not).
Fields
Numeric
Score a plain-English criterion on a numeric scale and compare it to a threshold.
Fields
comparator: ComparatorHow the score is compared to threshold. Defaults to >=.
Called
Deterministic: assert the referenced mock/spy observed at least one
matching call (or exactly times). Evaluated against the mock channel’s
records, not by a judge.
Fields
where: BTreeMap<String, FieldPredicate>Optional per-field input predicates narrowing which calls count.
NotCalled
Deterministic: assert the referenced mock/spy observed no matching call.
Implementations§
Source§impl Eval
impl Eval
Sourcepub fn criterion(&self) -> Option<&str>
pub fn criterion(&self) -> Option<&str>
The criterion text the judge sees; None for the deterministic
(called/not_called) kinds, which no judge ever scores.
Sourcepub fn label(&self) -> String
pub fn label(&self) -> String
A short label for reports: the explicit name if given, else the
criterion (judge kinds) or called: <mock> / not_called: <mock>.
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate the eval’s own parameters (independent of any transcript).
§Errors
Error::Invalid when a criterion is empty, a numeric scale is
degenerate (min >= max), the threshold falls outside [min, max], a
call eval references an empty mock name or asks for times: 0, or a
where predicate is malformed.
Sourcepub fn outcome_for_calls(
&self,
count: usize,
observed: &str,
) -> Result<EvalOutcome>
pub fn outcome_for_calls( &self, count: usize, observed: &str, ) -> Result<EvalOutcome>
Apply a deterministic call eval’s pass rule to the number of matching
observed calls, producing an outcome. Only meaningful for
Eval::Called/Eval::NotCalled; the runner never routes judge
kinds here.
§Errors
Error::Invalid if invoked on a judge-backed eval kind (a runner bug,
surfaced loudly rather than scored vacuously).
Sourcepub fn outcome(&self, raw: &JudgeValue, reason: String) -> Result<EvalOutcome>
pub fn outcome(&self, raw: &JudgeValue, reason: String) -> Result<EvalOutcome>
Apply this eval’s pass rule to a raw judge value, producing an outcome.
raw is the value the judge returned: JudgeValue::Bool for boolean
evals, JudgeValue::Number for numeric. A mismatch is a provider error.
§Errors
Error::Provider if the judge returned the wrong value kind for this
eval.