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 S6 rows with their Common Lisp values: a closure whose body names
//! a function or macro that does not outlive its unit is not carried.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const LABELS_K: &str = "(defvar *k* (labels ((h (y) (* y 10))) (lambda (x) (h x))))";
const DBL: &str = "(defmacro dbl (x) `(* ,x 2))";
fn rows() -> Vec<Row> {
vec![
row("B1", &[LABELS_K, "'*k*"]),
row("B2", &[LABELS_K, "(+ 1 2) '*k*"]),
row("B3", &[LABELS_K, "(funcall *k* 3)"]),
row(
"B4",
&[
DBL,
"(defvar *k* (lambda (y) (dbl y)))",
"(defmacro dbl (x) `(* ,x 3))",
"(funcall *k* 1)",
],
),
"B6",
&[DBL, "(defvar *k* (lambda (y) (dbl y)))", "(funcall *k* 4)"],
"B7",
"(defvar *k* (lambda (y) (mapcar (lambda (z) (dbl z)) (list y))))",
"B5",
"(defvar *k* (lambda (x) (when (> x 0) 1)))",
"(funcall *k* 3)",
]
}
/// CL: B1/B2 `*k*`, B3 30, B4 2, B5 1. B3 stays loud (the LABELS function does not
/// survive); B4 keeps the body expanded at creation.
const TODAY: &[(&str, &[&str])] = &[
("B1", &["-", "*k*"]),
("B2", &["-", "*k*"]),
("B3", &["-", LOST]),
("B4", &["dbl", "-", "dbl", "2"]),
("B6", &["dbl", "-", "8"]),
("B7", &["dbl", "-", "dbl", "(2)"]),
("B5", &["-", "1"]),
];
const LOST: &str = "err: Compile error: *K*: its closure value does n";
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), TODAY);