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 with their Common Lisp values: a runtime variable a function
6
//! kept from a binder that ended is not read from a separately compiled
7
//! function's own locals.
8

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

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

            
14
const KEEP: &str = "(let ((r (+ 5 (entity-count)))) (defun cnt () r))";
15

            
16
1
fn rows() -> Vec<Row> {
17
1
    vec![
18
1
        row(
19
1
            "M1",
20
1
            &[&format!(
21
1
                "(progn {KEEP} (defun rec (n a b c d e f g h i j k) (if (= n 0) (cnt) (rec (- n 1) a b c d e f g h i j k))) (rec (+ 2 (entity-count)) 11 12 13 14 15 16 17 18 19 20 21))"
22
1
            )],
23
1
        ),
24
1
        row(
25
1
            "M2",
26
1
            &[&format!(
27
1
                "(progn {KEEP} (defun rec (n a b) (let ((x 1) (y 2) (z 3) (w 4)) (if (= n 0) (cnt) (rec (- n 1) a b)))) (rec (+ 2 (entity-count)) 11 12))"
28
1
            )],
29
1
        ),
30
1
        row(
31
1
            "M3",
32
1
            &[&format!(
33
1
                "(progn {KEEP} (defun rec (n) (if (= n 0) (cnt) (rec (- n 1)))) (rec (+ 2 (entity-count))))"
34
1
            )],
35
1
        ),
36
    ]
37
1
}
38

            
39
const RUNTIME: &str = "err: Compile error: CNT: reads R, a runtime varia";
40

            
41
/// CL: M1 5, M2 5, M3 5. A runtime variable does not outlive its unit, so
42
/// all three stay loud rather than reading a local of the helper.
43
const TODAY: &[(&str, &[&str])] = &[("M1", &[RUNTIME]), ("M2", &[RUNTIME]), ("M3", &[RUNTIME])];
44

            
45
#[test]
46
1
fn every_row_reads_as_common_lisp() {
47
1
    assert_pinned(&rows(), TODAY);
48
1
}