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: a LET that rebinds a parameter of a self-recursive function
//! hides the argument's type from the return-type guess.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, row};
const LET_STAR: &str = "(defun f (p n) (if (> n 0) (let* ((q 1) (p (+ q (f p (- n 1))))) p) 0))";
const COND_LET: &str = "(defun f (p n) (cond ((> n 0) (let ((p (* 2 (f p (- n 1))))) p)) (t 1)))";
fn rows() -> Vec<Row> {
vec![
row("P2a", &[LET_STAR, "(f \"s\" (+ (entity-count) 3))"]),
row("P2b", &[COND_LET, "(f \"s\" (+ (entity-count) 3))"]),
row(
"P2c",
&[
"(defun f (p n) (if (> n 0) (let ((q (f p (- n 1)))) p) 0))",
"(f 5 (+ (entity-count) 3))",
],
),
]
}
const CL: &[(&str, &[&str])] = &[
("P2a", &["f", "3"]),
("P2b", &["f", "8"]),
("P2c", &["f", "5"]),
];
#[test]
fn every_row_reads_as_common_lisp() {
assert_pinned(&rows(), CL);