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 with their Common Lisp values: a `DO` variable that holds a
//! function is sized as the function it holds.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const STEP: &str = "(lambda () 5)";
fn rows() -> Vec<Row> {
vec![
row(
"O1",
&[&format!(
"(do ((f (lambda () 1) {STEP}) (i 0 (+ i 1))) ((= i 2) (funcall f)))"
)],
),
"O2",
"(do* ((f (lambda () 1) {STEP}) (i 0 (+ i 1))) ((= i 2) (funcall f)))"
"O3",
&[
&format!(
"(do ((f (lambda () 1) {STEP}) (i 0 (+ i 1))) ((= i (entity-count)) (funcall f)))"
"(do ((f (lambda () 1) {STEP}) (i 0 (+ i 1))) ((= i (+ 2 (entity-count))) (funcall f)))"
],
"O4",
"(do ((f (lambda (x) x) (lambda (x) (* x 2))) (i 0 (+ i 1))) ((= i 3) (funcall f 4)))",
"O5",
"(defun g (n) (do ((f (lambda () 1) {STEP}) (i 0 (+ i 1))) ((= i n) (funcall f))))"
"(g 2)",
"O6",
&["(do ((f (lambda () 1)) (i 0 (+ i 1))) ((= i 2) (funcall f)))"],
"O7",
&["(do ((f (lambda () 1) \"s\") (i 0 (+ i 1))) ((= i 2) f))"],
]
}
/// CL: O1/O2 5, O3 1 then 5, O4 8, O5 5, O6 1, O7 "s".
const TODAY: &[(&str, &[&str])] = &[
("O1", &["5"]),
("O2", &["5"]),
("O3", &["1", "5"]),
("O4", &["8"]),
("O5", &["g", "5"]),
("O6", &["1"]),
("O7", &["\"s\""]),
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), TODAY);