sim_lib_lang_lua/
conformance.rs1use sim_kernel::{Cx, Result, Symbol};
4use sim_lib_standard_core::{
5 LanguageProfile, MatrixRunReport, MatrixRunner, SourceConformanceCase, SourceExpectation,
6 SourceObservation,
7};
8
9use crate::{lua_core_matrix_row, lua_core_profile};
10
11pub fn run_lua_core_conformance_case(
13 _cx: &mut Cx,
14 case: &SourceConformanceCase,
15) -> Result<SourceObservation> {
16 Ok(observe_profile_backed_case(
17 case,
18 &lua_core_profile(),
19 Symbol::qualified("lua", "unsupported-source-case"),
20 "case is outside Lua profile descriptor coverage",
21 ))
22}
23
24pub fn run_lua_core_matrix_row(cx: &mut Cx) -> Result<MatrixRunReport> {
26 let row = lua_core_matrix_row();
27 let report = MatrixRunner::run_row(cx, &row, run_lua_core_conformance_case);
28 report.publish_claims(cx)?;
29 Ok(report)
30}
31
32fn observe_profile_backed_case(
33 case: &SourceConformanceCase,
34 profile: &LanguageProfile,
35 unsupported_code: Symbol,
36 unsupported_reason: &str,
37) -> SourceObservation {
38 match &case.expectation {
39 SourceExpectation::ExpectedGap { code, reason } => SourceObservation::Gap {
40 code: code.clone(),
41 reason: reason.clone(),
42 },
43 SourceExpectation::LowersTo(_) if case.source == "profile" => {
44 SourceObservation::LowersTo(profile_display(profile))
45 }
46 SourceExpectation::LowersTo(_) => SourceObservation::Gap {
47 code: unsupported_code,
48 reason: unsupported_reason.to_owned(),
49 },
50 }
51}
52
53fn profile_display(profile: &LanguageProfile) -> String {
54 format!(
55 "profile:{} reader:{} lowering:{}",
56 profile.symbol, profile.reader, profile.lowering
57 )
58}
59
60#[cfg(test)]
61mod tests {
62 use sim_kernel::testing::bare_cx as cx;
63 use sim_lib_standard_core::standard_test_capability;
64
65 use super::*;
66
67 #[test]
68 fn lua_core_matrix_row_runner_reports_profile_pass_and_runtime_gap() {
69 let mut cx = cx();
70 cx.grant(standard_test_capability());
71
72 let report = run_lua_core_matrix_row(&mut cx).unwrap();
73
74 assert_eq!(report.cells.len(), 2);
75 assert_eq!(report.pass_count(), 1);
76 assert_eq!(report.gap_count(), 1);
77 assert_eq!(report.fail_count(), 0);
78 }
79}