pub enum Eval {
Boolean(BooleanEval),
Numeric(NumericEval),
Called(CalledEval),
NotCalled(NotCalledEval),
}Expand description
An eval specification, as written in a test case’s YAML (or compiled by an SDK’s case builders).
Newtype variants on purpose: serde cannot deny_unknown_fields on an
internally tagged enum, but it does enforce it on the variant structs, so
a typo’d eval field (expcted:) is a loud parse error instead of a
silently-applied default. The variant titles name the generated SDK model
for each union arm, so keep them stable: they are part of the SDK API
surface (the input contract, schemas/case.schema.json).
Variants§
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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Eval
impl<'de> Deserialize<'de> for Eval
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Eval
impl JsonSchema for Eval
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more