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: nested DO loops whose nil-init steps each exit through the
//! outer BLOCK compile inside the work budget, as Common Lisp reads them.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const N: &str = "(defvar *n* (length (list 1 2)))";
/// `depth` DO loops, each stepping its variable through the next inner one.
fn nested(depth: usize) -> String {
let mut form =
"(do ((i1 0 (+ i1 1)) (v1 nil (if (> i1 5) (return-from b 1) (list i1)))) ((= i1 *n*) v1))"
.to_string();
for level in 2..=depth {
form = format!(
"(do ((i{level} 0 (+ i{level} 1)) (v{level} nil (if (> i{level} 7) (return-from b 2) {form}))) ((= i{level} *n*) v{level}))"
);
}
format!("(block b {form})")
fn rows() -> Vec<Row> {
vec![row("V2a", &[N, &nested(4)]), row("V2b", &[N, &nested(5)])]
const CL: &[(&str, &[&str])] = &[("V2a", &["-", "(1)"]), ("V2b", &["-", "(1)"])];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), CL);