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 DEFUN uses the macros in
6
//! force where it is defined in its parameter defaults too, and a macro of
7
//! its own name defined before it is not used inside it.
8

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

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

            
14
const DOUBLE: &str = "(defmacro m (x) `(* ,x 2))";
15
const TRIPLE: &str = "(defmacro m (x) `(* ,x 3))";
16
const PAIR: &str = "(defun m (x) (list x))";
17

            
18
1
fn rows() -> Vec<Row> {
19
1
    vec![
20
1
        row(
21
1
            "D1",
22
1
            &[
23
1
                "(defmacro f (x) `(list ,x))",
24
1
                "(defun f (n) (if (= n 0) 0 (f (- n 1))))",
25
1
                "(f 3)",
26
1
            ],
27
1
        ),
28
1
        row(
29
1
            "D2",
30
1
            &[
31
1
                DOUBLE,
32
1
                "(defun opt (&optional (y (m 1))) y)",
33
1
                TRIPLE,
34
1
                "(opt)",
35
1
            ],
36
1
        ),
37
1
        row(
38
1
            "D3",
39
1
            &[DOUBLE, "(defun kw (&key (y (m 1))) y)", TRIPLE, "(kw)"],
40
1
        ),
41
1
        row(
42
1
            "D4",
43
1
            &[DOUBLE, "(defun ax (&aux (y (m 1))) y)", TRIPLE, "(ax)"],
44
1
        ),
45
1
        row(
46
1
            "D5",
47
1
            &[DOUBLE, "(defun opt (&optional (y (m 1))) y)", PAIR, "(opt)"],
48
1
        ),
49
1
        row(
50
1
            "D6",
51
1
            &[DOUBLE, "(defun kw (&key (y (m 1))) y)", PAIR, "(kw)"],
52
1
        ),
53
1
        row(
54
1
            "D7",
55
1
            &[DOUBLE, "(defun ax (&aux (y (m 1))) y)", PAIR, "(ax)"],
56
1
        ),
57
    ]
58
1
}
59

            
60
/// CL: D1 0, D2 2, D3 2, D4 2, D5 2, D6 2, D7 2.
61
const TODAY: &[(&str, &[&str])] = &[
62
    ("D1", &["f", "f", "0"]),
63
    ("D2", &["m", "opt", "m", "2"]),
64
    ("D3", &["m", "kw", "m", "2"]),
65
    ("D4", &["m", "ax", "m", "2"]),
66
    ("D5", &["m", "opt", "m", "2"]),
67
    ("D6", &["m", "kw", "m", "2"]),
68
    ("D7", &["m", "ax", "m", "2"]),
69
];
70

            
71
#[test]
72
1
fn every_row_reads_as_common_lisp() {
73
1
    assert_pinned(&rows(), TODAY);
74
1
}