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 custom SHOULD-APPLY reads a carried global the unit writes
6
//! as the earlier unit left it, and the unit's store still lands.
7

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

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

            
13
const RESET: &str = "(defun should-apply () 1)";
14

            
15
1
fn rows() -> Vec<Row> {
16
1
    vec![
17
1
        row(
18
1
            "T1a",
19
1
            &[
20
1
                "(defvar *m* 5)",
21
1
                "(defun should-apply () (if (= *m* 5) 1 0)) (setf *m* 6)",
22
1
                RESET,
23
1
                "*m*",
24
1
            ],
25
1
        ),
26
1
        row(
27
1
            "T1b",
28
1
            &[
29
1
                "(defvar *l* (list 1 2))",
30
1
                "(defun should-apply () (if (equal *l* (list 1 2)) 1 0)) (setf *l* (list 3))",
31
1
                RESET,
32
1
                "*l*",
33
1
            ],
34
1
        ),
35
1
        row(
36
1
            "T1c",
37
1
            &[
38
1
                "(defvar *s* \"abc\")",
39
1
                "(defun should-apply () (if (string= *s* \"abc\") 1 0)) (setf *s* \"xyz\")",
40
1
                RESET,
41
1
                "*s*",
42
1
            ],
43
1
        ),
44
1
        row(
45
1
            "T1d",
46
1
            &[
47
1
                "(defstruct pt x)",
48
1
                "(defvar *p* (make-pt :x 1))",
49
1
                "(defun should-apply () (if (= (pt-x *p*) 1) 1 0)) (setf *p* (make-pt :x 9))",
50
1
                RESET,
51
1
                "(pt-x *p*)",
52
1
            ],
53
1
        ),
54
1
        row(
55
1
            "T1f",
56
1
            &[
57
1
                "(defvar *f* (lambda (x) (+ x 1)))",
58
1
                "(defun should-apply () (if (= (funcall *f* 1) 2) 1 0)) (setf *f* (lambda (x) (+ x 2)))",
59
1
                RESET,
60
1
                "(funcall *f* 1)",
61
1
            ],
62
1
        ),
63
    ]
64
1
}
65

            
66
const CL: &[(&str, &[&str])] = &[
67
    ("T1a", &["-", "-", "-", "6"]),
68
    ("T1b", &["-", "-", "-", "(3)"]),
69
    ("T1c", &["-", "-", "-", "\"xyz\""]),
70
    ("T1d", &["pt", "-", "-", "-", "9"]),
71
    ("T1f", &["-", "-", "-", "3"]),
72
];
73

            
74
#[test]
75
1
fn every_row_reads_as_common_lisp() {
76
1
    assert_pinned(&rows(), CL);
77
1
}