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 user macro is not a function,
6
//! so no function designator names one; a built-in implemented as a macro is a
7
//! function in Common Lisp, and a designator of it says it cannot be lowered yet.
8

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

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

            
14
const DBL: &str = "(defmacro dbl (x) `(* ,x 2))";
15

            
16
1
fn rows() -> Vec<Row> {
17
1
    vec![
18
1
        row("F1", &[DBL, "(mapcar (function dbl) '(1 2))"]),
19
1
        row("F2", &[DBL, "(apply 'dbl (list 3))"]),
20
1
        row("F3", &[DBL, "(funcall 'dbl 3)"]),
21
1
        row("F4", &[DBL, "(mapcar 'dbl '(1 2))"]),
22
1
        row(
23
1
            "F5",
24
1
            &[DBL, "(dbl 3)", "(mapcar (lambda (x) (dbl x)) '(1 2))"],
25
1
        ),
26
1
        row(
27
1
            "B1",
28
1
            &["(funcall (function mapcar) (lambda (x) (+ x 1)) '(1 2))"],
29
1
        ),
30
1
        row(
31
1
            "B2",
32
1
            &["(apply (function mapcar) (list (lambda (x) (+ x 1)) '(1 2)))"],
33
1
        ),
34
1
        row("B3", &["(funcall 'mapc (lambda (x) x) '(1 2))"]),
35
1
        row("B4", &["(funcall 'mapcar (lambda (x) x) '(1 2))"]),
36
1
        row("B5", &["(mapcar (lambda (x) (+ x 1)) '(1 2))"]),
37
    ]
38
1
}
39

            
40
const NOT_FUNCTION: &str = "err: Compile error: DBL is a macro, not a functio";
41

            
42
const NOT_LOWERED_MAPCAR: &str = "err: Compile error: MAPCAR cannot be used as a fu";
43
const NOT_LOWERED_MAPC: &str = "err: Compile error: MAPC cannot be used as a func";
44

            
45
/// CL: F1-F4 are errors, F5 is 6 and (2 4); B1 (2 3), B2 (2 3), B3 (1 2),
46
/// B4 (1 2) where a built-in used as a function value is refused, B5 (2 3).
47
const TODAY: &[(&str, &[&str])] = &[
48
    ("F1", &["dbl", NOT_FUNCTION]),
49
    ("F2", &["dbl", NOT_FUNCTION]),
50
    ("F3", &["dbl", NOT_FUNCTION]),
51
    ("F4", &["dbl", NOT_FUNCTION]),
52
    ("F5", &["dbl", "6", "(2 4)"]),
53
    ("B1", &[NOT_LOWERED_MAPCAR]),
54
    ("B2", &[NOT_LOWERED_MAPCAR]),
55
    ("B3", &[NOT_LOWERED_MAPC]),
56
    ("B4", &[NOT_LOWERED_MAPCAR]),
57
    ("B5", &["(2 3)"]),
58
];
59

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