Lines
100 %
Functions
Branches
// Skipped under Miri: these tests compile+run wasm via wasmtime, whose
// Cranelift backend refuses to run under Miri.
#![cfg(not(miri))]
//! PERSIST rows: what a variable hides of a function name is given back when
//! its binder ends, whichever binder made it and whatever LABELS nests.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const MACRO_M: &str = "(defmacro m (x) `(* ,x 2))";
const CALL_M: &str = "(let ((m 5)) (m 1))";
fn rows() -> Vec<Row> {
vec![
row(
"H1",
&[
"(labels ((m (x) (+ x 1))) (dolist (m (list 1 2)) (m m)))",
CALL_M,
],
),
"H2",
"(labels ((m (x) (+ x 1))) (do ((m 0 (+ m 1))) ((= m 2) (m m))))",
"H3",
MACRO_M,
"(let ((m 1)) (list (labels ((m (x) (+ x 1))) (let ((m 2)) (m 10))) (m 3)))",
"H4",
"(let ((m 1)) (labels ((m (x) (+ x 1))) (let ((m 2)) (m 10))) (m 3))",
"H5",
"(labels ((m (x) (+ x 1))) (let ((m 4)) (list (labels ((m (x) (- x 1))) (let ((m 3)) (m m))) (m m))))",
"H6",
"(let ((m 1)) (list (labels ((m (x) (+ x 1))) (let ((m 2)) (m m))) (m m)))",
"H7",
"(let ((m (+ 1 (entity-count)))) (list (labels ((m (x) (+ x 1))) (let ((m 2)) (m 5))) (m 3)))",
"H8",
"(let ((m 1)) (labels ((m (x) (+ x 1))) (let ((m 2)) 0)) (m 3))",
]
}
const NOT_CALLABLE: &str = "err: Compile error: symbol 'M' is not callable";
/// CL: H1 and H2 end in an undefined-function error, the rest are the values.
const TODAY: &[(&str, &[&str])] = &[
("H1", &["nil", NOT_CALLABLE]),
("H2", &["3", NOT_CALLABLE]),
("H3", &["m", "(11 6)"]),
("H4", &["m", "6"]),
("H5", &["m", "(2 5)"]),
("H6", &["m", "(3 2)"]),
("H7", &["m", "(6 6)"]),
("H8", &["m", "6"]),
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), TODAY);