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: SETF macroexpands a macro place
6
//! (CLHS 5.1.2.7) and stores into the place the expansion names.
7

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

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

            
13
const PT: &str = "(defstruct pt x)";
14
const PX: &str = "(defmacro px (p) `(pt-x ,p))";
15
const N: &str = "(defvar *n* 0)";
16
const MY_N: &str = "(defmacro my-n () '*n*)";
17

            
18
1
fn rows() -> Vec<Row> {
19
1
    vec![
20
1
        row(
21
1
            "P1",
22
1
            &[
23
1
                PT,
24
1
                PX,
25
1
                "(let ((p (make-pt :x 1))) (setf (px p) 3) (pt-x p))",
26
1
            ],
27
1
        ),
28
1
        row("P2", &[N, MY_N, "(setf (my-n) 5)", "*n*"]),
29
1
        row(
30
1
            "P3",
31
1
            &[
32
1
                PT,
33
1
                PX,
34
1
                "(let ((p (make-pt :x 1))) (list (setf (px p) 4) (px p)))",
35
1
            ],
36
1
        ),
37
1
        row(
38
1
            "P4",
39
1
            &[
40
1
                "(defmacro loc () 'k)",
41
1
                "(let ((k (entity-count))) (setf (loc) 7) k)",
42
1
            ],
43
1
        ),
44
1
        row(
45
1
            "P5",
46
1
            &[N, MY_N, "(defun bump () (setf (my-n) 9))", "(bump)", "*n*"],
47
1
        ),
48
1
        row(
49
1
            "P6",
50
1
            &[
51
1
                PT,
52
1
                "(defmacro inner (p) `(px ,p))",
53
1
                PX,
54
1
                "(let ((p (make-pt :x 1))) (setf (inner p) 6) (pt-x p))",
55
1
            ],
56
1
        ),
57
1
        row("P7", &[PT, "(setf (no-such-place 1) 3)"]),
58
1
        row("P8", &[PT, "(let ((p (make-pt :x 1))) (setf (pt-x p) 4))"]),
59
    ]
60
1
}
61

            
62
const UNKNOWN: &str = "err: Compile error: No setf method defined for ac";
63

            
64
/// CL: P1 3, P2 5 and *n* 5, P3 (4 4), P4 7, P5 9 and *n* 9, P6 6, P7 an error, P8 4.
65
const TODAY: &[(&str, &[&str])] = &[
66
    ("P1", &["pt", "px", "3"]),
67
    ("P2", &["-", "my-n", "5", "5"]),
68
    ("P3", &["pt", "px", "(4 4)"]),
69
    ("P4", &["loc", "7"]),
70
    ("P5", &["-", "my-n", "bump", "9", "9"]),
71
    ("P6", &["pt", "inner", "px", "6"]),
72
    ("P7", &["pt", UNKNOWN]),
73
    ("P8", &["pt", "4"]),
74
];
75

            
76
#[test]
77
1
fn every_row_reads_as_common_lisp() {
78
1
    assert_pinned(&rows(), TODAY);
79
1
}