use crate::descriptor::{
CheckRef, ClaimRef, Classification, ExecutionSuite, PopulationRef, SubjectRoute,
};
use crate::muterprater::proposal::types::{
CandidateSketch, CheckGap, DischargeEvidence, ExplanationRefusal, InferredObligation,
ObligationLane, OracleClass, OwedClaim, OwedClaimRefusal, OwedDeclaration, ProofShape,
SurvivorExplanation,
};
use crate::muterprater::{MutationReport, MutationTarget, MutationVerdict};
use crate::report::{ClaimExercise, ExecutionKey, TrialId};
impl SurvivorExplanation {
pub fn of(
report: &MutationReport,
missing: OracleClass,
closing: CheckRef,
) -> Result<Self, ExplanationRefusal> {
let verdict = report.verdict();
match verdict {
MutationVerdict::Survived => {}
MutationVerdict::Killed | MutationVerdict::Inconclusive => {
return Err(ExplanationRefusal::NotASurvivor(verdict));
}
}
let Some(claim) = report.target().owning_claim() else {
return Err(ExplanationRefusal::OwnerUnmapped);
};
Ok(Self {
target: report.target().clone(),
claim,
missing,
closing,
})
}
#[must_use]
pub const fn target(&self) -> &MutationTarget {
&self.target
}
#[must_use]
pub const fn claim(&self) -> ClaimRef {
self.claim
}
#[must_use]
pub const fn missing(&self) -> OracleClass {
self.missing
}
#[must_use]
pub const fn closing(&self) -> CheckRef {
self.closing
}
}
impl CheckGap {
pub const fn found(claim: ClaimRef, check: CheckRef, missing: OracleClass) -> Self {
Self {
claim,
check,
missing,
}
}
#[must_use]
pub const fn claim(self) -> ClaimRef {
self.claim
}
#[must_use]
pub const fn check(self) -> CheckRef {
self.check
}
#[must_use]
pub const fn missing(self) -> OracleClass {
self.missing
}
}
impl CandidateSketch {
#[must_use]
pub fn stated(
suite: ExecutionSuite,
classification: Classification,
subject: SubjectRoute,
population: PopulationRef,
) -> Self {
Self {
suite,
classification,
subject,
population,
}
}
#[must_use]
pub const fn suite(&self) -> ExecutionSuite {
self.suite
}
#[must_use]
pub const fn classification(&self) -> &Classification {
&self.classification
}
#[must_use]
pub const fn subject(&self) -> SubjectRoute {
self.subject
}
#[must_use]
pub const fn population(&self) -> PopulationRef {
self.population
}
}
impl OwedClaim {
pub const fn declared(
claim: ClaimRef,
opening_condition: &'static str,
) -> Result<Self, OwedClaimRefusal> {
if opening_condition.is_empty() {
return Err(OwedClaimRefusal::NoOpeningCondition);
}
Ok(Self {
claim,
opening_condition,
})
}
#[must_use]
pub const fn claim(self) -> ClaimRef {
self.claim
}
#[must_use]
pub const fn opening_condition(self) -> &'static str {
self.opening_condition
}
}
impl OwedDeclaration {
#[must_use]
pub const fn stated(owed: OwedClaim, shape: ProofShape) -> Self {
Self { owed, shape }
}
#[must_use]
pub const fn owed(self) -> OwedClaim {
self.owed
}
#[must_use]
pub const fn shape(self) -> ProofShape {
self.shape
}
}
impl InferredObligation {
#[must_use]
pub const fn inferred(owed: OwedClaim, exercise: ClaimExercise, shape: ProofShape) -> Self {
Self {
owed,
exercise,
shape,
}
}
#[must_use]
pub const fn owed(self) -> OwedClaim {
self.owed
}
#[must_use]
pub const fn exercise(self) -> ClaimExercise {
self.exercise
}
#[must_use]
pub const fn shape(self) -> ProofShape {
self.shape
}
}
impl DischargeEvidence {
#[must_use]
pub fn recorded(lane: ObligationLane, trial: TrialId, key: ExecutionKey) -> Self {
Self { lane, trial, key }
}
#[must_use]
pub const fn lane(&self) -> ObligationLane {
self.lane
}
#[must_use]
pub const fn trial(&self) -> TrialId {
self.trial
}
#[must_use]
pub const fn key(&self) -> &ExecutionKey {
&self.key
}
}