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 S6 rows with their Common Lisp values: a unit that stores another
//! closure or declares the name special.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const K: &str = "(defvar *k* (lambda (x) x))";
const Q: &str = "(setf *q* (lambda (x) x))";
fn rows() -> Vec<Row> {
vec![
row(
"C1",
&[K, "(defparameter *k* (lambda (x) 0)) (funcall *k* 5)"],
),
row("C2", &[K, "(setf *k* (lambda (x) 2)) (+ 1 2)"]),
row("C3", &[K, "(defvar *k* (lambda (x) 0)) (+ 1 2)"]),
"C4",
&[
"(defvar *f* (lambda () 0))",
"(let* ((a 1) (b (+ a (entity-count)))) (setf *f* (lambda () (list a b))))",
],
"C5",
Q,
"(defvar *q*)",
"(setf *q* 3)",
"(defun h () *q*) (let ((*q* 7)) (h))",
"C6",
"(defun h () (funcall *q* 1)) (let ((*q* (lambda (x) 9))) (h))",
]
}
/// CL: C1 0, C2 3, C3 3, C4 a closure, C5 7, C6 9.
const TODAY: &[(&str, &[&str])] = &[
("C1", &["-", "0"]),
("C2", &["-", "3"]),
("C3", &["-", "3"]),
("C4", &["-", "#<closure:0>"]),
("C5", &["#<closure:0>", "-", "3", "7"]),
("C6", &["#<closure:0>", "-", "9"]),
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), TODAY);