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 nil accumulator built from
6
//! the result of a closure call is sized from the cons it stores.
7

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

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

            
13
const COUNT: &str = "(= i (+ 2 (entity-count)))";
14

            
15
1
fn rows() -> Vec<Row> {
16
1
    vec![
17
1
        row(
18
1
            "N1",
19
1
            &[&format!(
20
1
                "(let ((acc nil) (f (lambda () 5))) (do ((i 0 (+ i 1))) ({COUNT} acc) (setf acc (cons (funcall f) acc))))"
21
1
            )],
22
1
        ),
23
1
        row(
24
1
            "N2",
25
1
            &[&format!(
26
1
                "(let ((f (lambda () 5))) (do ((acc nil (cons (funcall f) acc)) (i 0 (+ i 1))) ({COUNT} acc)))"
27
1
            )],
28
1
        ),
29
1
        row(
30
1
            "N3",
31
1
            &[&format!(
32
1
                "(let* ((f (lambda () 5)) (acc nil)) (do ((i 0 (+ i 1))) ({COUNT} acc) (setf acc (cons (funcall f) acc))))"
33
1
            )],
34
1
        ),
35
1
        row(
36
1
            "N4",
37
1
            &[&format!(
38
1
                "(let ((f (lambda () \"s\")) (acc nil)) (do ((i 0 (+ i 1))) ({COUNT} acc) (setf acc (cons (funcall f) acc))))"
39
1
            )],
40
1
        ),
41
1
        row(
42
1
            "N5",
43
1
            &[
44
1
                "(let ((f (lambda () 5))) (let ((f (lambda () (funcall f))) (acc nil)) (setf acc (cons (funcall f) acc)) acc))",
45
1
            ],
46
1
        ),
47
1
        row(
48
1
            "N6",
49
1
            &[&format!(
50
1
                "(let ((f (lambda () 5))) (let ((f (lambda () (funcall f))) (acc nil)) (do ((i 0 (+ i 1))) ({COUNT} acc) (setf acc (cons (funcall f) acc)))))"
51
1
            )],
52
1
        ),
53
1
        row(
54
1
            "N7",
55
1
            &[&format!(
56
1
                "(let ((x \"s\")) (let ((acc nil) (f (lambda (x) x))) (do ((i 0 (+ i 1))) ({COUNT} acc) (setf acc (cons (funcall f 1) acc)))))"
57
1
            )],
58
1
        ),
59
    ]
60
1
}
61

            
62
/// CL: N1 (5 5), N2 (5 5), N3 (5 5), N4 ("s" "s"), N5 (5), N6 (5 5), N7 (1 1).
63
const TODAY: &[(&str, &[&str])] = &[
64
    ("N1", &["(5 5)"]),
65
    ("N2", &["(5 5)"]),
66
    ("N3", &["(5 5)"]),
67
    ("N4", &["(\"s\" \"s\")"]),
68
    ("N5", &["(5)"]),
69
    ("N6", &["(5 5)"]),
70
    ("N7", &["(1 1)"]),
71
];
72

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