1
// Skipped under Miri: these tests compile+run wasm via wasmtime, whose
2
// Cranelift backend refuses to run under Miri.
3
#![cfg(not(miri))]
4

            
5
//! PERSIST: a later unit over many carried instances compiles, runs and
6
//! reads the right value through the interpreter.
7

            
8
use nms::interpreter::Interpreter;
9

            
10
1
fn carried(count: u32) -> Interpreter {
11
1
    let mut interp = Interpreter::new(false).unwrap();
12
1
    interp.eval("(defstruct pt x)").unwrap();
13
1
    let fill = format!(
14
1
        "(defvar *ps* (do ((i 0 (+ i 1)) (acc nil (cons (make-pt :x i) acc))) ((= i {count}) acc)))"
15
    );
16
1
    interp.eval(&fill).unwrap();
17
1
    interp
18
1
}
19

            
20
#[test]
21
1
fn a_later_unit_runs_over_many_carried_instances() {
22
1
    let mut interp = carried(8_000);
23
1
    let outcome = interp.eval("(+ 1 (pt-x (car *ps*)))");
24
1
    assert!(outcome.is_ok(), "{outcome:?}");
25
1
    assert!(format!("{outcome:?}").contains("8000"), "{outcome:?}");
26
1
}