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: SETF macroexpands a macro place
//! (CLHS 5.1.2.7) and stores into the place the expansion names.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const PT: &str = "(defstruct pt x)";
const PX: &str = "(defmacro px (p) `(pt-x ,p))";
const N: &str = "(defvar *n* 0)";
const MY_N: &str = "(defmacro my-n () '*n*)";
fn rows() -> Vec<Row> {
vec![
row(
"P1",
&[
PT,
PX,
"(let ((p (make-pt :x 1))) (setf (px p) 3) (pt-x p))",
],
),
row("P2", &[N, MY_N, "(setf (my-n) 5)", "*n*"]),
"P3",
"(let ((p (make-pt :x 1))) (list (setf (px p) 4) (px p)))",
"P4",
"(defmacro loc () 'k)",
"(let ((k (entity-count))) (setf (loc) 7) k)",
"P5",
&[N, MY_N, "(defun bump () (setf (my-n) 9))", "(bump)", "*n*"],
"P6",
"(defmacro inner (p) `(px ,p))",
"(let ((p (make-pt :x 1))) (setf (inner p) 6) (pt-x p))",
row("P7", &[PT, "(setf (no-such-place 1) 3)"]),
row("P8", &[PT, "(let ((p (make-pt :x 1))) (setf (pt-x p) 4))"]),
]
}
const UNKNOWN: &str = "err: Compile error: No setf method defined for ac";
/// CL: P1 3, P2 5 and *n* 5, P3 (4 4), P4 7, P5 9 and *n* 9, P6 6, P7 an error, P8 4.
const TODAY: &[(&str, &[&str])] = &[
("P1", &["pt", "px", "3"]),
("P2", &["-", "my-n", "5", "5"]),
("P3", &["pt", "px", "(4 4)"]),
("P4", &["loc", "7"]),
("P5", &["-", "my-n", "bump", "9", "9"]),
("P6", &["pt", "inner", "px", "6"]),
("P7", &["pt", UNKNOWN]),
("P8", &["pt", "4"]),
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), TODAY);