use super::{CompilationDisagreement, CompilationVerdict, CompiledDisagreement, CompiledVerdict};
use crate::oracle::ORACLE_CAUSE_FAMILY;
use crate::report::{FailureClass, FindingCause, FindingLocation, TrialConclusion, TrialFinding};
const fn cause(found: &CompiledDisagreement) -> FindingCause {
let local = match found {
CompiledDisagreement::AcceptedWhereRefusalDeclared => {
"compiled-accepted-where-refusal-declared"
}
CompiledDisagreement::RefusedWhereAcceptanceDeclared => {
"compiled-refused-where-acceptance-declared"
}
CompiledDisagreement::UnexpectedMember { .. } => "compiled-unexpected-member",
CompiledDisagreement::DuplicateMember { .. } => "compiled-duplicate-member",
CompiledDisagreement::MissingMember { .. } => "compiled-missing-member",
CompiledDisagreement::MemberValue { .. } => "compiled-member-value",
};
FindingCause::named(ORACLE_CAUSE_FAMILY, local)
}
impl CompiledVerdict {
#[must_use]
pub fn concluded(&self, located: FindingLocation) -> TrialConclusion {
match self {
Self::Conforms => TrialConclusion::Passed,
Self::Deviates(found) => TrialConclusion::Refused(TrialFinding::established(
FailureClass::OracleDisagreement,
cause(found),
located,
None,
)),
}
}
}
const fn compilation_cause(found: &CompilationDisagreement) -> FindingCause {
let local = match found {
CompilationDisagreement::AcceptedWhereRefusalDeclared => {
"compiled-diagnostic-accepted-where-refusal-declared"
}
CompilationDisagreement::RefusedWhereAcceptanceDeclared { .. } => {
"compiled-diagnostic-refused-where-acceptance-declared"
}
CompilationDisagreement::ErrorCode { .. } => "compiled-diagnostic-error-code",
CompilationDisagreement::PrimarySpan { .. } => "compiled-diagnostic-primary-span",
};
FindingCause::named(ORACLE_CAUSE_FAMILY, local)
}
impl CompilationVerdict {
#[must_use]
pub fn concluded(&self, located: FindingLocation) -> TrialConclusion {
match self {
Self::Conforms => TrialConclusion::Passed,
Self::Deviates(found) => TrialConclusion::Refused(TrialFinding::established(
FailureClass::OracleDisagreement,
compilation_cause(found),
located,
None,
)),
}
}
}