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 DEFUN uses the macros in
//! force where it is defined in its parameter defaults too, and a macro of
//! its own name defined before it is not used inside it.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const DOUBLE: &str = "(defmacro m (x) `(* ,x 2))";
const TRIPLE: &str = "(defmacro m (x) `(* ,x 3))";
const PAIR: &str = "(defun m (x) (list x))";
fn rows() -> Vec<Row> {
vec![
row(
"D1",
&[
"(defmacro f (x) `(list ,x))",
"(defun f (n) (if (= n 0) 0 (f (- n 1))))",
"(f 3)",
],
),
"D2",
DOUBLE,
"(defun opt (&optional (y (m 1))) y)",
TRIPLE,
"(opt)",
"D3",
&[DOUBLE, "(defun kw (&key (y (m 1))) y)", TRIPLE, "(kw)"],
"D4",
&[DOUBLE, "(defun ax (&aux (y (m 1))) y)", TRIPLE, "(ax)"],
"D5",
&[DOUBLE, "(defun opt (&optional (y (m 1))) y)", PAIR, "(opt)"],
"D6",
&[DOUBLE, "(defun kw (&key (y (m 1))) y)", PAIR, "(kw)"],
"D7",
&[DOUBLE, "(defun ax (&aux (y (m 1))) y)", PAIR, "(ax)"],
]
}
/// CL: D1 0, D2 2, D3 2, D4 2, D5 2, D6 2, D7 2.
const TODAY: &[(&str, &[&str])] = &[
("D1", &["f", "f", "0"]),
("D2", &["m", "opt", "m", "2"]),
("D3", &["m", "kw", "m", "2"]),
("D4", &["m", "ax", "m", "2"]),
("D5", &["m", "opt", "m", "2"]),
("D6", &["m", "kw", "m", "2"]),
("D7", &["m", "ax", "m", "2"]),
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), TODAY);