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))]
//! PERSIST rows with their Common Lisp values: `&body` is `&rest` in a macro
//! lambda list only, and any other `&` name in a lambda list is an error.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, assert_pinned_wide, row};
fn accepted() -> Vec<Row> {
vec![
row(
"B1",
&[
"(defmacro my-progn (&body b) `(progn ,@b))",
"(my-progn (print 1) 5)",
],
),
"B2",
"(defmacro wrap (&body body) `(list ,@body))",
"(wrap 1 2 3)",
"B3",
"(defmacro req (a &body body) `(list ,a ,@body))",
"(req 1 2 3)",
"B4",
"(defmacro destr ((a &body bs) c) `(list ,a ',bs ,c))",
"(destr (1 2 3) 4)",
row("B13", &["(defmacro mr (&rest b) `(list ,@b))", "(mr 1 2)"]),
"B14",
"(defun fk (a &optional (b 2) &key (c 3)) (list a b c))",
"(fk 1)",
]
}
fn refused() -> Vec<Row> {
row("B5", &["(defun f5 (&body x) x)"]),
row("B6", &["(funcall (lambda (&body x) x) 1 2)"]),
row("B7", &["(defun f7 (&foo x) x)"]),
row("B8", &["(defmacro m8 (&foo x) x)"]),
row("B9", &["(defmacro m9 (&body a &rest b) a)"]),
row("B10", &["(defmacro m10 (&rest a &body b) a)"]),
row("B11", &["(defmacro m11 (a &body) a)"]),
row("B12", &["(defun f12 (&environment e) e)"]),
row("B15", &["(defun f15 (&rest r &optional x) (list r x))"]),
row("B16", &["(defmacro m16 (&rest r &optional x) r)"]),
row("B17", &["(defun f17 (a &rest r &optional) a)"]),
/// CL: B1 5 (prints 1), B2 and B3 (1 2 3), B4 (1 (2 3) 4), B13 (1 2), B14
/// (1 2 3). B1-B3 moved: &body is now &rest in a macro. B4 stays an error, a
/// macro lambda list has no destructuring.
const ACCEPTED: &[(&str, &[&str])] = &[
("B1", &["my-progn", "5"]),
("B2", &["wrap", "(1 2 3)"]),
("B3", &["req", "(1 2 3)"]),
(
"err: Compile error: DEFMACRO: required parameter ",
"err: Undefined symbol: DESTR",
("B13", &["mr", "(1 2)"]),
("B14", &["fk", "(1 2 3)"]),
];
/// CL: B5, B6, B9-B11 and B15-B17 (SBCL: misplaced &OPTIONAL) are errors; B7, B8 and B12 are errors by the
/// owner's Q2 decision (SBCL only warns). B5-B8, B11 and B12 moved from
/// accepted; B9 and B10 now report the second rest parameter.
const REFUSED: &[(&str, &[&str])] = &[
"B5",
&["err: Compile error: DEFUN: &body is allowed in a macro lambda list only"],
"B6",
&["err: Compile error: LAMBDA: &body is allowed in a macro lambda list only"],
"B7",
&["err: Compile error: DEFUN: unknown lambda list keyword &FOO"],
"B8",
&["err: Compile error: DEFMACRO: unknown lambda list keyword &FOO"],
"B9",
&["err: Compile error: DEFMACRO: multiple &rest parameters"],
"B10",
"B11",
&["err: Compile error: DEFMACRO: &body needs a parameter"],
"B12",
&["err: Compile error: DEFUN: unknown lambda list keyword &ENVIRONMENT"],
"B15",
&["err: Compile error: DEFUN: &OPTIONAL after post-&rest"],
"B16",
&["err: Compile error: DEFMACRO: &OPTIONAL after post-&rest"],
"B17",
#[test]
fn accepted_rows_read_as_common_lisp() {
assert_pinned(&accepted(), ACCEPTED);
fn refused_rows_are_compile_errors() {
assert_pinned_wide(&refused(), REFUSED, 70);