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: a LET that rebinds a parameter of a self-recursive function
6
//! hides the argument's type from the return-type guess.
7

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

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

            
13
const LET_STAR: &str = "(defun f (p n) (if (> n 0) (let* ((q 1) (p (+ q (f p (- n 1))))) p) 0))";
14
const COND_LET: &str = "(defun f (p n) (cond ((> n 0) (let ((p (* 2 (f p (- n 1))))) p)) (t 1)))";
15

            
16
1
fn rows() -> Vec<Row> {
17
1
    vec![
18
1
        row("P2a", &[LET_STAR, "(f \"s\" (+ (entity-count) 3))"]),
19
1
        row("P2b", &[COND_LET, "(f \"s\" (+ (entity-count) 3))"]),
20
1
        row(
21
1
            "P2c",
22
1
            &[
23
1
                "(defun f (p n) (if (> n 0) (let ((q (f p (- n 1)))) p) 0))",
24
1
                "(f 5 (+ (entity-count) 3))",
25
1
            ],
26
1
        ),
27
    ]
28
1
}
29

            
30
const CL: &[(&str, &[&str])] = &[
31
    ("P2a", &["f", "3"]),
32
    ("P2b", &["f", "8"]),
33
    ("P2c", &["f", "5"]),
34
];
35

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