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
//! `#'x` is `'x` for a built-in everywhere, as a value too, and one rule
6
//! names what is no function designator (plan L2-4c).
7

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

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

            
13
24
fn whole(label: &'static str, forms: &[&str]) -> Row {
14
24
    row(label, &[&forms.join(" ")])
15
24
}
16

            
17
1
fn rows() -> Vec<Row> {
18
1
    vec![
19
1
        whole("let-car", &["(let ((g #'car)) (funcall g (list 1 2)))"]),
20
1
        whole("let-plus", &["(let ((g #'+)) (apply g (list 1 2)))"]),
21
1
        whole(
22
1
            "param",
23
1
            &["(defun app2 (g a b) (funcall g a b)) (app2 #'+ 1 2)"],
24
1
        ),
25
1
        whole(
26
1
            "param-map",
27
1
            &["(defun mc (g xs) (mapcar g xs)) (mc #'car (list (list 1 2) (list 3 4)))"],
28
1
        ),
29
1
        whole(
30
1
            "in-list",
31
1
            &["(mapcar (lambda (g) (funcall g 10 2)) (list #'+ #'-))"],
32
1
        ),
33
1
        whole(
34
1
            "returned",
35
1
            &["(defun getf1 () #'car) (funcall (getf1) (list 5 6))"],
36
1
        ),
37
1
        whole(
38
1
            "chosen",
39
1
            &[
40
1
                "(defun pick (k) (if k #'+ #'-)) (list (funcall (pick t) 5 2) (funcall (pick nil) 5 2))",
41
1
            ],
42
1
        ),
43
1
        whole("computed", &["(funcall (car (list #'+)) 1 2)"]),
44
1
        whole("computed-quoted", &["(funcall (car (list '+)) 1 2)"]),
45
1
        whole("funcall-of-funcall", &["(funcall #'funcall #'+ 1 2)"]),
46
1
        whole("funcall-quoted", &["(funcall 'funcall '+ 1 2)"]),
47
1
        whole("apply-of-apply", &["(funcall #'apply #'+ (list 1 2))"]),
48
1
        whole("eval-map", &["(mapcar #'eval (list 1 2))"]),
49
1
        whole("if-quoted", &["(funcall 'if t 1 2)"]),
50
1
        whole("if-sharp", &["(funcall #'if t 1 2)"]),
51
1
        whole("and-quoted", &["(funcall 'and 1 2)"]),
52
1
        whole("or-sharp", &["(funcall #'or nil 2)"]),
53
1
        whole("when-quoted", &["(funcall 'when t 1)"]),
54
1
        whole("unless-sharp", &["(funcall #'unless nil 1)"]),
55
1
        whole("cond-map", &["(mapcar #'cond (list 1))"]),
56
1
        whole("let-sharp", &["(funcall #'let nil 1)"]),
57
1
        whole("one-plus-quoted", &["(funcall '1+ 4)"]),
58
1
        whole("one-minus-map", &["(mapcar #'1- (list 1 2))"]),
59
1
        whole(
60
1
            "mapcar-sharp",
61
1
            &["(funcall #'mapcar #'car (list (list 1 2)))"],
62
1
        ),
63
    ]
64
1
}
65

            
66
#[test]
67
1
fn a_built_in_designator_is_one_value_in_both_spellings() {
68
1
    assert_pinned(
69
1
        &rows(),
70
1
        &[
71
1
            ("let-car", &["1"]),
72
1
            ("let-plus", &["3"]),
73
1
            ("param", &["3"]),
74
1
            ("param-map", &["(1 3)"]),
75
1
            ("in-list", &["(12 8)"]),
76
1
            ("returned", &["5"]),
77
1
            ("chosen", &["(7 3)"]),
78
1
            ("computed", &["3"]),
79
1
            ("computed-quoted", &["3"]),
80
1
            ("funcall-of-funcall", &["3"]),
81
1
            ("funcall-quoted", &["3"]),
82
1
            ("apply-of-apply", &["3"]),
83
1
            ("eval-map", &["(1 2)"]),
84
1
            (
85
1
                "if-quoted",
86
1
                &["err: Compile error: IF is a special operator, not"],
87
1
            ),
88
1
            (
89
1
                "if-sharp",
90
1
                &["err: Compile error: IF is a special operator, not"],
91
1
            ),
92
1
            (
93
1
                "and-quoted",
94
1
                &["err: Compile error: AND is a macro, not a functio"],
95
1
            ),
96
1
            (
97
1
                "or-sharp",
98
1
                &["err: Compile error: OR is a macro, not a function"],
99
1
            ),
100
1
            (
101
1
                "when-quoted",
102
1
                &["err: Compile error: WHEN is a macro, not a functi"],
103
1
            ),
104
1
            (
105
1
                "unless-sharp",
106
1
                &["err: Compile error: UNLESS is a macro, not a func"],
107
1
            ),
108
1
            (
109
1
                "cond-map",
110
1
                &["err: Compile error: COND is a macro, not a functi"],
111
1
            ),
112
1
            (
113
1
                "let-sharp",
114
1
                &["err: Compile error: LET is a special operator, no"],
115
1
            ),
116
1
            (
117
1
                "one-plus-quoted",
118
1
                &["err: Compile error: 1+ cannot be used as a functi"],
119
1
            ),
120
1
            (
121
1
                "one-minus-map",
122
1
                &["err: Compile error: 1- cannot be used as a functi"],
123
1
            ),
124
1
            (
125
1
                "mapcar-sharp",
126
1
                &["err: Compile error: MAPCAR cannot be used as a fu"],
127
1
            ),
128
1
        ],
129
1
    );
130
1
}