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 unit whose process never runs, or whose SHOULD-APPLY reads
//! a carried struct instance, leaves every carried instance as it was.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const PT: &str = "(defstruct pt x)";
const P: &str = "(defvar *p* (make-pt :x 1))";
const BUMP: &str = "(setf (pt-x *p*) 2)";
fn rows() -> Vec<Row> {
vec![
row(
"A1",
&[
PT,
P,
BUMP,
"(defun should-apply () 0) (+ 1 1)",
"(pt-x *p*)",
],
),
"A2",
"(defun should-apply () (error 'boom \"x\")) (+ 1 1)",
"A3",
"(defun should-apply () (if (= (pt-x *p*) 2) 1 0)) (setf (pt-x *p*) 3)",
"(defun should-apply () 1)",
"A4",
"(defvar *l* (list *p* (make-pt :x 5)))",
"(setf (pt-x (car (cdr *l*))) 6)",
"(defun should-apply () 0) 1",
"(list (pt-x *p*) (pt-x (car *l*)) (pt-x (car (cdr *l*))) (eq *p* (car *l*)))",
"A5",
"(defstruct node val next)",
"(defvar *a* (make-node :val 1))",
"(defvar *b* (make-node :val 2 :next *a*))",
"(progn (setf (node-next *a*) *b*) 1)",
"(list (node-val (node-next (node-next *a*))) (eq *a* (node-next *b*)))",
"A6",
"(defvar *f* (lambda () (pt-x *p*)))",
"(setf (pt-x *p*) 7)",
"(funcall *f*)",
"A7",
"(defun should-apply () (progn (setf (pt-x *p*) 8) 1)) 0",
]
}
const REFUSED: &str = "err: should_apply returned 0, expected 1";
const CL: &[(&str, &[&str])] = &[
("A1", &["pt", "-", "2", REFUSED, "2"]),
("A2", &["pt", "-", "2", "err: BOOM: x", "2"]),
("A3", &["pt", "-", "2", "-", "-", "3"]),
("A4", &["pt", "-", "-", "6", REFUSED, "(1 1 6 t)"]),
("A5", &["node", "-", "-", "1", REFUSED, "(1 t)"]),
("A6", &["pt", "-", "-", "7", REFUSED, "7"]),
("A7", &["pt", "-", "-", "8"]),
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), CL);