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 S6 rows with their Common Lisp values: a unit that stores another
6
//! closure or declares the name special.
7

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

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

            
13
const K: &str = "(defvar *k* (lambda (x) x))";
14
const Q: &str = "(setf *q* (lambda (x) x))";
15

            
16
1
fn rows() -> Vec<Row> {
17
1
    vec![
18
1
        row(
19
1
            "C1",
20
1
            &[K, "(defparameter *k* (lambda (x) 0)) (funcall *k* 5)"],
21
1
        ),
22
1
        row("C2", &[K, "(setf *k* (lambda (x) 2)) (+ 1 2)"]),
23
1
        row("C3", &[K, "(defvar *k* (lambda (x) 0)) (+ 1 2)"]),
24
1
        row(
25
1
            "C4",
26
1
            &[
27
1
                "(defvar *f* (lambda () 0))",
28
1
                "(let* ((a 1) (b (+ a (entity-count)))) (setf *f* (lambda () (list a b))))",
29
1
            ],
30
1
        ),
31
1
        row(
32
1
            "C5",
33
1
            &[
34
1
                Q,
35
1
                "(defvar *q*)",
36
1
                "(setf *q* 3)",
37
1
                "(defun h () *q*) (let ((*q* 7)) (h))",
38
1
            ],
39
1
        ),
40
1
        row(
41
1
            "C6",
42
1
            &[
43
1
                Q,
44
1
                "(defvar *q*)",
45
1
                "(defun h () (funcall *q* 1)) (let ((*q* (lambda (x) 9))) (h))",
46
1
            ],
47
1
        ),
48
    ]
49
1
}
50

            
51
/// CL: C1 0, C2 3, C3 3, C4 a closure, C5 7, C6 9.
52
const TODAY: &[(&str, &[&str])] = &[
53
    ("C1", &["-", "0"]),
54
    ("C2", &["-", "3"]),
55
    ("C3", &["-", "3"]),
56
    ("C4", &["-", "#<closure:0>"]),
57
    ("C5", &["#<closure:0>", "-", "3", "7"]),
58
    ("C6", &["#<closure:0>", "-", "9"]),
59
];
60

            
61
#[test]
62
1
fn every_row_reads_as_common_lisp() {
63
1
    assert_pinned(&rows(), TODAY);
64
1
}