sim_lib_lang_islisp/
matrix_row.rs1use sim_kernel::Symbol;
4use sim_lib_standard_core::{
5 LanguageRow, LanguageRowBuilder, SourceConformanceCase, SourceConformanceCaseKind,
6 SourceExpectation,
7};
8
9use crate::{islisp_lowering_symbol, islisp_profile, islisp_reader_symbol};
10
11pub fn islisp_matrix_row() -> LanguageRow {
13 LanguageRowBuilder::new(Symbol::new("islisp"), islisp_profile())
14 .with_cases(islisp_source_cases())
15 .build()
16}
17
18pub fn islisp_source_cases() -> Vec<SourceConformanceCase> {
20 vec![
21 SourceConformanceCase {
22 symbol: Symbol::qualified("test/islisp", "profile-declared"),
23 organ: islisp_reader_symbol(),
24 source_name: "profile.sim".to_owned(),
25 source: "profile".to_owned(),
26 kind: SourceConformanceCaseKind::DescriptorOnly,
27 expectation: SourceExpectation::LowersTo(islisp_profile_display()),
28 affects_badge: Some(Symbol::qualified("standard", "partial")),
29 },
30 SourceConformanceCase {
31 symbol: Symbol::qualified("test/islisp", "runtime-gap"),
32 organ: islisp_lowering_symbol(),
33 source_name: "runtime-gap.lisp".to_owned(),
34 source: "(eval '(+ 1 2))".to_owned(),
35 kind: SourceConformanceCaseKind::DescriptorOnly,
36 expectation: SourceExpectation::ExpectedGap {
37 code: Symbol::qualified("islisp", "runtime-gap"),
38 reason: "ISLISP full evaluator execution is outside this row".to_owned(),
39 },
40 affects_badge: None,
41 },
42 ]
43}
44
45fn islisp_profile_display() -> String {
46 let profile = islisp_profile();
47 format!(
48 "profile:{} reader:{} lowering:{}",
49 profile.symbol, profile.reader, profile.lowering
50 )
51}
52
53#[cfg(test)]
54mod tests {
55 use super::*;
56
57 #[test]
58 fn islisp_matrix_row_language_symbol_is_islisp() {
59 let row = islisp_matrix_row();
60
61 assert_eq!(row.language, Symbol::new("islisp"));
62 assert!(!row.is_empty());
63 assert_eq!(row.cases.len(), 2);
64 assert!(matches!(
65 row.cases[0].expectation,
66 SourceExpectation::LowersTo(_)
67 ));
68 assert!(matches!(
69 row.cases[1].expectation,
70 SourceExpectation::ExpectedGap { .. }
71 ));
72 }
73}