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 nil-init DO variable is sized by the value its step yields,
//! whatever the step's leading forms. An Index or scalar cannot hold the nil
//! seed, so its home is any value.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const PT: &str = "(defstruct pt x)";
const G: &str = "(defvar *g* 0)";
fn counting(step: &str) -> String {
format!(
"(let ((p (make-pt)) (n (length (list 1 2)))) (do ((i 0 (+ i 1)) (v nil {step})) ((= i n) v)))"
)
}
fn rows() -> Vec<Row> {
vec![
row("H3a", &[PT, G, &counting("(progn (setf *g* i) i)")]),
row("H3b", &[PT, G, &counting("(setf (pt-x p) i)")]),
row("H3c", &[PT, G, &counting("(progn (setf *g* i) 1/2)")]),
row("H3d", &[PT, G, &counting("i")]),
row("H3e", &[PT, G, &counting("(progn (setf *g* i) \"s\")")]),
row(
"H3f",
&[PT, G, &counting("(progn (setf *g* i) (cons i v))")],
),
row("H3g", &[PT, G, &counting("(make-pt :x v)")]),
row("H3h", &[PT, G, &counting("(cons i v)")]),
]
/// CL: H3a 1, H3b 1, H3c 1/2, H3d 1, H3e "s", H3f (1 0), H3g
/// #S(PT :X #S(PT :X nil)), H3h (1 0).
const CL: &[(&str, &[&str])] = &[
("H3a", &["pt", "-", "1"]),
("H3b", &["pt", "-", "1"]),
("H3c", &["pt", "-", "1/2"]),
("H3d", &["pt", "-", "1"]),
("H3e", &["pt", "-", "\"s\""]),
("H3f", &["pt", "-", "(1 0)"]),
("H3g", &["pt", "-", "#S(PT :X #S(PT :X nil))"]),
("H3h", &["pt", "-", "(1 0)"]),
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), CL);