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: a struct held in a field of another reads back as the
//! struct, even through an accessor named like a predicate (BOX-P).
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const PT: &str = "(defstruct pt x)";
const BOX: &str = "(defstruct box p)";
const HELD: &str = "(make-box :p (make-pt :x 8))";
fn rows() -> Vec<Row> {
vec![
row("N1", &[PT, BOX, &format!("(pt-p (box-p {HELD}))")]),
row("N2", &[PT, BOX, &format!("(pt-x (box-p {HELD}))")]),
row("N3", &[BOX, "(box-p (make-box :p 5))"]),
row(
"N4",
&[
BOX,
"(let ((b (make-box :p 1))) (setf (box-p b) 7) (box-p b))",
],
),
row("N5", &[BOX, "(box-p 5)"]),
]
}
/// CL: t, 8, 5, 7, and a type error for the last.
const TODAY: &[(&str, &[&str])] = &[
("N1", &["pt", "box", "t"]),
("N2", &["pt", "box", "8"]),
("N3", &["box", "5"]),
("N4", &["box", "7"]),
(
"N5",
&["box", "err: Compile error: BOX-P: expected a BOX, got an"],
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), TODAY);