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 struct held in a field of another reads back as the
6
//! struct, even through an accessor named like a predicate (BOX-P).
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 BOX: &str = "(defstruct box p)";
15
const HELD: &str = "(make-box :p (make-pt :x 8))";
16

            
17
1
fn rows() -> Vec<Row> {
18
1
    vec![
19
1
        row("N1", &[PT, BOX, &format!("(pt-p (box-p {HELD}))")]),
20
1
        row("N2", &[PT, BOX, &format!("(pt-x (box-p {HELD}))")]),
21
1
        row("N3", &[BOX, "(box-p (make-box :p 5))"]),
22
1
        row(
23
1
            "N4",
24
1
            &[
25
1
                BOX,
26
1
                "(let ((b (make-box :p 1))) (setf (box-p b) 7) (box-p b))",
27
1
            ],
28
1
        ),
29
1
        row("N5", &[BOX, "(box-p 5)"]),
30
    ]
31
1
}
32

            
33
/// CL: t, 8, 5, 7, and a type error for the last.
34
const TODAY: &[(&str, &[&str])] = &[
35
    ("N1", &["pt", "box", "t"]),
36
    ("N2", &["pt", "box", "8"]),
37
    ("N3", &["box", "5"]),
38
    ("N4", &["box", "7"]),
39
    (
40
        "N5",
41
        &["box", "err: Compile error: BOX-P: expected a BOX, got an"],
42
    ),
43
];
44

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