Lines
86.67 %
Functions
50 %
Branches
100 %
// Skipped under Miri: these tests compile+run wasm via wasmtime, whose
// Cranelift backend refuses to run under Miri.
#![cfg(not(miri))]
//! A `setf` inside a binding init yields the stored value to the expression
//! around it.
use nms::interpreter::Interpreter;
use scripting::nomiscript::{Number, Value};
fn eval_last(src: &str) -> Value {
let mut interp = Interpreter::new(false).unwrap();
let results = interp
.eval(src)
.unwrap_or_else(|e| panic!("eval {src:?}: {e}"));
results
.into_iter()
.next_back()
.unwrap_or_else(|| panic!("eval {src:?} produced no value"))
}
#[test]
fn a_store_keeps_its_value_in_the_enclosing_expression() {
assert_eq!(
eval_last("(let ((x 0)) (let ((z (+ 1 (setf x 5)))) z))"),
Value::Number(Number::Index(6))
);