Lines
100 %
Functions
Branches
// Skipped under Miri: these tests compile+run wasm via wasmtime, whose
// Cranelift backend refuses to run under Miri.
#![cfg(not(miri))]
//! `#'x` is `'x` for a built-in everywhere, as a value too, and one rule
//! names what is no function designator (plan L2-4c).
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
fn whole(label: &'static str, forms: &[&str]) -> Row {
row(label, &[&forms.join(" ")])
}
fn rows() -> Vec<Row> {
vec![
whole("let-car", &["(let ((g #'car)) (funcall g (list 1 2)))"]),
whole("let-plus", &["(let ((g #'+)) (apply g (list 1 2)))"]),
whole(
"param",
&["(defun app2 (g a b) (funcall g a b)) (app2 #'+ 1 2)"],
),
"param-map",
&["(defun mc (g xs) (mapcar g xs)) (mc #'car (list (list 1 2) (list 3 4)))"],
"in-list",
&["(mapcar (lambda (g) (funcall g 10 2)) (list #'+ #'-))"],
"returned",
&["(defun getf1 () #'car) (funcall (getf1) (list 5 6))"],
"chosen",
&[
"(defun pick (k) (if k #'+ #'-)) (list (funcall (pick t) 5 2) (funcall (pick nil) 5 2))",
],
whole("computed", &["(funcall (car (list #'+)) 1 2)"]),
whole("computed-quoted", &["(funcall (car (list '+)) 1 2)"]),
whole("funcall-of-funcall", &["(funcall #'funcall #'+ 1 2)"]),
whole("funcall-quoted", &["(funcall 'funcall '+ 1 2)"]),
whole("apply-of-apply", &["(funcall #'apply #'+ (list 1 2))"]),
whole("eval-map", &["(mapcar #'eval (list 1 2))"]),
whole("if-quoted", &["(funcall 'if t 1 2)"]),
whole("if-sharp", &["(funcall #'if t 1 2)"]),
whole("and-quoted", &["(funcall 'and 1 2)"]),
whole("or-sharp", &["(funcall #'or nil 2)"]),
whole("when-quoted", &["(funcall 'when t 1)"]),
whole("unless-sharp", &["(funcall #'unless nil 1)"]),
whole("cond-map", &["(mapcar #'cond (list 1))"]),
whole("let-sharp", &["(funcall #'let nil 1)"]),
whole("one-plus-quoted", &["(funcall '1+ 4)"]),
whole("one-minus-map", &["(mapcar #'1- (list 1 2))"]),
"mapcar-sharp",
&["(funcall #'mapcar #'car (list (list 1 2)))"],
]
#[test]
fn a_built_in_designator_is_one_value_in_both_spellings() {
assert_pinned(
&rows(),
("let-car", &["1"]),
("let-plus", &["3"]),
("param", &["3"]),
("param-map", &["(1 3)"]),
("in-list", &["(12 8)"]),
("returned", &["5"]),
("chosen", &["(7 3)"]),
("computed", &["3"]),
("computed-quoted", &["3"]),
("funcall-of-funcall", &["3"]),
("funcall-quoted", &["3"]),
("apply-of-apply", &["3"]),
("eval-map", &["(1 2)"]),
(
"if-quoted",
&["err: Compile error: IF is a special operator, not"],
"if-sharp",
"and-quoted",
&["err: Compile error: AND is a macro, not a functio"],
"or-sharp",
&["err: Compile error: OR is a macro, not a function"],
"when-quoted",
&["err: Compile error: WHEN is a macro, not a functi"],
"unless-sharp",
&["err: Compile error: UNLESS is a macro, not a func"],
"cond-map",
&["err: Compile error: COND is a macro, not a functi"],
"let-sharp",
&["err: Compile error: LET is a special operator, no"],
"one-plus-quoted",
&["err: Compile error: 1+ cannot be used as a functi"],
"one-minus-map",
&["err: Compile error: 1- cannot be used as a functi"],
&["err: Compile error: MAPCAR cannot be used as a fu"],
);