koala-core 1.0.4

Shared types, invariant evaluator, and primitives for the koala framework.
Documentation
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Outcome {
    Pass {
        info: Option<String>,
    },
    Fail {
        detail: String,
        reproduce: Option<String>,
    },
    Skip {
        reason: String,
    },
}

impl Outcome {
    pub fn pass() -> Self {
        Self::Pass { info: None }
    }

    pub fn pass_with(info: impl Into<String>) -> Self {
        Self::Pass {
            info: Some(info.into()),
        }
    }

    pub fn fail(detail: impl Into<String>) -> Self {
        Self::Fail {
            detail: detail.into(),
            reproduce: None,
        }
    }

    pub fn fail_repro(detail: impl Into<String>, reproduce: impl Into<String>) -> Self {
        Self::Fail {
            detail: detail.into(),
            reproduce: Some(reproduce.into()),
        }
    }

    pub fn skip(reason: impl Into<String>) -> Self {
        Self::Skip {
            reason: reason.into(),
        }
    }

    pub fn is_fail(&self) -> bool {
        matches!(self, Self::Fail { .. })
    }

    pub fn is_skip(&self) -> bool {
        matches!(self, Self::Skip { .. })
    }

    pub fn label(&self) -> &'static str {
        match self {
            Self::Pass { .. } => "PASS",
            Self::Fail { .. } => "FAIL",
            Self::Skip { .. } => "SKIP",
        }
    }
}