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 user macro is not a function,
//! so no function designator names one; a built-in implemented as a macro is a
//! function in Common Lisp, and a designator of it says it cannot be lowered yet.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const DBL: &str = "(defmacro dbl (x) `(* ,x 2))";
fn rows() -> Vec<Row> {
vec![
row("F1", &[DBL, "(mapcar (function dbl) '(1 2))"]),
row("F2", &[DBL, "(apply 'dbl (list 3))"]),
row("F3", &[DBL, "(funcall 'dbl 3)"]),
row("F4", &[DBL, "(mapcar 'dbl '(1 2))"]),
row(
"F5",
&[DBL, "(dbl 3)", "(mapcar (lambda (x) (dbl x)) '(1 2))"],
),
"B1",
&["(funcall (function mapcar) (lambda (x) (+ x 1)) '(1 2))"],
"B2",
&["(apply (function mapcar) (list (lambda (x) (+ x 1)) '(1 2)))"],
row("B3", &["(funcall 'mapc (lambda (x) x) '(1 2))"]),
row("B4", &["(funcall 'mapcar (lambda (x) x) '(1 2))"]),
row("B5", &["(mapcar (lambda (x) (+ x 1)) '(1 2))"]),
]
}
const NOT_FUNCTION: &str = "err: Compile error: DBL is a macro, not a functio";
const NOT_LOWERED_MAPCAR: &str = "err: Compile error: MAPCAR cannot be used as a fu";
const NOT_LOWERED_MAPC: &str = "err: Compile error: MAPC cannot be used as a func";
/// CL: F1-F4 are errors, F5 is 6 and (2 4); B1 (2 3), B2 (2 3), B3 (1 2),
/// B4 (1 2) where a built-in used as a function value is refused, B5 (2 3).
const TODAY: &[(&str, &[&str])] = &[
("F1", &["dbl", NOT_FUNCTION]),
("F2", &["dbl", NOT_FUNCTION]),
("F3", &["dbl", NOT_FUNCTION]),
("F4", &["dbl", NOT_FUNCTION]),
("F5", &["dbl", "6", "(2 4)"]),
("B1", &[NOT_LOWERED_MAPCAR]),
("B2", &[NOT_LOWERED_MAPCAR]),
("B3", &[NOT_LOWERED_MAPC]),
("B4", &[NOT_LOWERED_MAPCAR]),
("B5", &["(2 3)"]),
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), TODAY);