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 body uses the macros
6
//! in force where the DEFUN is defined, not the definitions that come later.
7

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

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

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

            
17
1
fn rows() -> Vec<Row> {
18
1
    vec![
19
1
        row("X1", &[DOUBLE, "(defun use () (m 5))", PAIR, "(use)"]),
20
1
        row("X2", &[DOUBLE, "(defun use () (m 5))", TRIPLE, "(use)"]),
21
1
        row("X3", &[DOUBLE, "(defun use (k) (m k))", TRIPLE, "(use 5)"]),
22
1
        row(
23
1
            "X4",
24
1
            &[
25
1
                DOUBLE,
26
1
                "(defun use (k) (m k))",
27
1
                TRIPLE,
28
1
                "(use (entity-count))",
29
1
            ],
30
1
        ),
31
1
        row(
32
1
            "X5",
33
1
            &[
34
1
                DOUBLE,
35
1
                "(defun use () (m 5))",
36
1
                PAIR,
37
1
                "(defun use2 () (m 5))",
38
1
                "(list (use) (use2))",
39
1
            ],
40
1
        ),
41
1
        row(
42
1
            "X6",
43
1
            &[DOUBLE, "(defun use () (when t (m 5)))", TRIPLE, "(use)"],
44
1
        ),
45
    ]
46
1
}
47

            
48
/// CL: X1 10, X2 10, X3 10, X4 0, X5 (10 (5 5)), X6 10.
49
const TODAY: &[(&str, &[&str])] = &[
50
    ("X1", &["m", "use", "m", "10"]),
51
    ("X2", &["m", "use", "m", "10"]),
52
    ("X3", &["m", "use", "m", "10"]),
53
    ("X4", &["m", "use", "m", "0"]),
54
    ("X5", &["m", "use", "m", "use2", "(10 (5 5))"]),
55
    ("X6", &["m", "use", "m", "10"]),
56
];
57

            
58
#[test]
59
1
fn every_row_reads_as_common_lisp() {
60
1
    assert_pinned(&rows(), TODAY);
61
1
}