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: an instance is made at run
//! time, so the effects of the form that makes it run exactly once.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const PT: &str = "(defstruct pt x)";
const N: &str = "(defvar *n* 0)";
fn rows() -> Vec<Row> {
vec![
row("E1", &[PT, N, "(+ (pt-x (make-pt :x (setf *n* 5))) *n*)"]),
row(
"E2",
&[PT, N, "(list (pt-x (make-pt :x (setf *n* 5))) *n*)"],
),
row("E3", &[PT, N, "(progn (make-pt :x (setf *n* 5)) 1)", "*n*"]),
"E4",
&[PT, N, "(progn (pt-p (make-pt :x (setf *n* 5))) *n*)"],
row("E5", &[PT, "(let ((n 0)) (make-pt :x (setf n 5)) n)"]),
"E6",
&[PT, "(let ((n (entity-count))) (make-pt :x (setf n 5)) n)"],
"E7",
&[
PT,
"(let ((n (entity-count))) (+ (pt-x (make-pt :x (setf n 5))) n))",
],
"E8",
"(let ((n (entity-count))) (let ((p (make-pt :x (setf n 5)))) n))",
"E9",
&[PT, N, "(let ((p (make-pt :x (setf *n* 5)))) (pt-x p))"],
"E10",
N,
"(defun gx (p) (pt-x p))",
"(gx (make-pt :x (setf *n* 5)))",
"E11",
"(defun mk () (make-pt :x 4))",
"(list (pt-x (mk)) (let ((p (mk))) (pt-x p)))",
"E12",
"(defun mk2 () (make-pt :x (setf *n* 4)))",
"(pt-x (mk2))",
]
}
/// CL: E1 10, E2 (5 5), E3 1 then *n* 5, E4 5, E5 5, E6 5, E7 10, E8 5, E9 5,
/// E10 5, E11 (4 4), E12 4.
const CL: &[(&str, &[&str])] = &[
("E1", &["pt", "-", "10"]),
("E2", &["pt", "-", "(5 5)"]),
("E3", &["pt", "-", "1", "5"]),
("E4", &["pt", "-", "5"]),
("E5", &["pt", "5"]),
("E6", &["pt", "5"]),
("E7", &["pt", "10"]),
("E8", &["pt", "5"]),
("E9", &["pt", "-", "5"]),
("E10", &["pt", "-", "gx", "5"]),
("E11", &["pt", "mk", "(4 4)"]),
("E12", &["pt", "-", "mk2", "4"]),
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), CL);