1
// Skipped under Miri: these tests compile+run wasm via wasmtime, whose
2
// Cranelift backend refuses to run under Miri.
3
#![cfg(not(miri))]
4

            
5
//! PERSIST rows: nested DO loops whose nil-init steps each exit through the
6
//! outer BLOCK compile inside the work budget, as Common Lisp reads them.
7

            
8
#[path = "persist/rows.rs"]
9
mod persist;
10

            
11
use persist::{Row, assert_pinned, row};
12

            
13
const N: &str = "(defvar *n* (length (list 1 2)))";
14

            
15
/// `depth` DO loops, each stepping its variable through the next inner one.
16
2
fn nested(depth: usize) -> String {
17
    let mut form =
18
2
        "(do ((i1 0 (+ i1 1)) (v1 nil (if (> i1 5) (return-from b 1) (list i1)))) ((= i1 *n*) v1))"
19
2
            .to_string();
20
2
    for level in 2..=depth {
21
7
        form = format!(
22
7
            "(do ((i{level} 0 (+ i{level} 1)) (v{level} nil (if (> i{level} 7) (return-from b 2) {form}))) ((= i{level} *n*) v{level}))"
23
7
        );
24
    }
25
2
    format!("(block b {form})")
26
2
}
27

            
28
1
fn rows() -> Vec<Row> {
29
1
    vec![row("V2a", &[N, &nested(4)]), row("V2b", &[N, &nested(5)])]
30
1
}
31

            
32
const CL: &[(&str, &[&str])] = &[("V2a", &["-", "(1)"]), ("V2b", &["-", "(1)"])];
33

            
34
#[test]
35
1
fn every_row_reads_as_common_lisp() {
36
1
    assert_pinned(&rows(), CL);
37
1
}