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: a field read widens the
//! global it is stored into, and SETF returns the stored value.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const PT: &str = "(defstruct pt x)";
fn rows() -> Vec<Row> {
vec![
row(
"G1a",
&[
PT,
"(defvar *g* 1)",
"(let ((p (make-pt :x 5))) (setf *g* (pt-x p)) (setf (pt-x p) \"x\") *g*)",
],
),
"G1b",
"(let ((p (make-pt))) (setf (pt-x p) 3) (defvar *c* (pt-x p)) *c*)",
"GA",
"(defvar *h* 5)",
"(setf *g* *h*) (setf *h* \"x\") *g*",
"GB",
&["(defvar *h* nil)", "(setf *h* 3) (defvar *c* *h*) *c*"],
"G2a",
&[PT, "(let ((p (make-pt))) (+ (setf (pt-x p) 2) 1))"],
"G2b",
&[PT, "(let ((p (make-pt))) (+ (setf (pt-x p) 1/2) 1/1))"],
]
}
/// CL: G1a 5, G1b 3, GA 5, GB 3, G2a 3, G2b 3/2.
const CL: &[(&str, &[&str])] = &[
("G1a", &["pt", "-", "5"]),
("G1b", &["pt", "3"]),
("GA", &["-", "-", "5"]),
("GB", &["-", "3"]),
("G2a", &["pt", "3"]),
("G2b", &["pt", "3/2"]),
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), CL);