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 AB rows: the region a possible exit skips starts at the exit
//! inside PROGN, LET and LET* bodies, so a definition textually before it is
//! kept and one after it is still refused.
#[path = "persist/rows.rs"]
mod persist;
use persist::{Row, assert_pinned, assert_pinned_wide, row};
const ALWAYS: &str = "(> (entity-count) -1)";
fn rows() -> Vec<Row> {
vec![
row(
"P1",
&[
&format!("(block b (progn (defun f () 1) (when {ALWAYS} (return-from b 1))) 0)"),
"(f)",
],
),
"P2",
&format!(
"(block b (let ((r 2)) (defun f () 1) (when {ALWAYS} (return-from b r))) 0)"
"P3",
"(handler-case (let ((x 1)) (defun f () 2) (print \"go\") x) (t (e) 0))",
"P3b",
"(handler-case (progn (progn (defun f () 2) (print \"go\")) 0) (t (e) 0))",
"P4",
&format!("(tagbody (progn (defun f () 2) (when {ALWAYS} (go end))) end)"),
"P5",
"(block b (let* ((r 2)) (progn (defun f () 1)) (when {ALWAYS} (return-from b r))) 0)"
"R1",
&format!("(block b (progn (when {ALWAYS} (return-from b 1)) (defun f () 1)) 0)"),
"R2",
"(block b (let ((r (if {ALWAYS} (return-from b 1) 2))) (defun f () r)) 0)"
"R3",
"(block b (progn (defun f () 1) (when {ALWAYS} (return-from b 1)) (defun f () 3)) 0)"
"R4",
"(block b (progn (progn (when {ALWAYS} (return-from b 1)) (defun f () 1)) 0))"
]
}
const KEPT: &[(&str, &[&str])] = &[
("P1", &["1", "1"]),
("P2", &["2", "1"]),
("P3", &["1", "2"]),
("P3b", &["0", "2"]),
("P4", &["-", "2"]),
("P5", &["2", "1"]),
];
const CLASH: &str = "err: Compile error: DEFUN F follows a form that may leave this BLOCK; move ";
const REFUSED: &[(&str, &[&str])] = &[
("R1", &[CLASH, "err: Undefined symbol: F"]),
("R2", &[CLASH, "err: Undefined symbol: F"]),
("R3", &[CLASH, "err: Undefined symbol: F"]),
("R4", &[CLASH, "err: Undefined symbol: F"]),
#[test]
fn a_definition_before_the_exit_inside_a_sequential_form_is_kept() {
assert_pinned(&rows()[..6], KEPT);
fn a_definition_after_the_exit_inside_a_sequential_form_is_refused() {
assert_pinned_wide(&rows()[6..], REFUSED, 70);