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 structure instance made in
//! argument position, and a field read of it used as a 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("P1", &[PT, "(pt-x (make-pt :x 1))"]),
row("P2", &[PT, "(let ((v (pt-x (make-pt :x 1)))) v)"]),
row(
"P3",
&[PT, "(defun gx (p) (pt-x p))", "(gx (make-pt :x 1))"],
),
"P4",
&[PT, "(funcall (lambda (p) (pt-x p)) (make-pt :x 1))"],
row("P5", &[PT, "(pt-x (car (list (make-pt :x 1))))"]),
row("P6", &[PT, "(+ 1 (pt-x (make-pt :x 1)))"]),
row("P7", &[PT, "(list (pt-x (make-pt :x 1)) 2)"]),
row("P8", &[PT, "(if (pt-p (make-pt :x 1)) 10 20)"]),
"P9",
&[
PT,
"(let ((p (make-pt :x 1))) (setf (pt-x p) 9) (+ 1 (pt-x p)))",
],
row("P10", &[PT, "(progn (make-pt :x 1) 5)"]),
"P11",
&[PT, "(length (list (make-pt :x 1) (make-pt :x 2)))"],
]
}
/// CL: P1 1, P2 1, P3 1, P4 1, P5 1, P6 2, P7 (1 2), P8 10, P9 10, P10 5, P11
/// 2.
const CL: &[(&str, &[&str])] = &[
("P1", &["pt", "1"]),
("P2", &["pt", "1"]),
("P3", &["pt", "gx", "1"]),
("P4", &["pt", "1"]),
("P5", &["pt", "1"]),
("P6", &["pt", "2"]),
("P7", &["pt", "(1 2)"]),
("P8", &["pt", "10"]),
("P9", &["pt", "10"]),
("P10", &["pt", "5"]),
("P11", &["pt", "2"]),
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), CL);