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: the function operand of a
//! `FUNCALL` may be a conditional choosing between functions.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const TRUE: &str = "(> (entity-count) -1)";
const FALSE: &str = "(> (entity-count) 99)";
fn rows() -> Vec<Row> {
vec![
row(
"F1",
&[&format!(
"(funcall (if {TRUE} (lambda () 1) (lambda () 2)))"
)],
),
"F2",
"(funcall (cond ({FALSE} (lambda (x) x)) (t (lambda (x) (* x 2)))) 3)"
"F3",
&[
&format!("(funcall (if {TRUE} (lambda () 1) (lambda () 2)))"),
&format!("(funcall (if {FALSE} (lambda () 1) (lambda () 2)))"),
],
"F4",
"(funcall (if {TRUE} (lambda () 1) (lambda (x) 2)))"
"F5",
"(funcall (if {TRUE} (lambda () 1) (lambda () \"s\")))"
"F6",
"(let ((f (if {TRUE} (lambda () 1) (lambda () 2)))) (funcall f))"
"F7",
"(funcall (unless {FALSE} (lambda (x) (+ x 1))) 4)"
]
}
/// CL: F1 1, F2 6, F3 1 then 2, F4 1, F5 1, F6 1, F7 5. A conditional whose
/// arms differ in type, or that may be nil, is an any value, called with a
/// run-time check.
const ROWS: &[(&str, &[&str])] = &[
("F1", &["1"]),
("F2", &["6"]),
("F3", &["1", "2"]),
("F4", &["1"]),
("F5", &["1"]),
("F6", &["1"]),
("F7", &["5"]),
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), ROWS);