Skip to main content

sim_kernel/
testing.rs

1//! Shared test-context constructors.
2//!
3//! Use these helpers instead of hand-rolling local `Cx` constructors in tests.
4//! The two constructors cover structure-only tests and eager-evaluation tests;
5//! a test module can route through them with
6//! `use sim_kernel::testing::bare_cx as cx;`.
7
8use std::sync::Arc;
9
10use crate::{Cx, DefaultFactory, EagerPolicy, NoopEvalPolicy};
11
12/// A bare evaluation context: the no-op eval policy over the default factory.
13///
14/// Use for tests that exercise structure without driving evaluation.
15pub fn bare_cx() -> Cx {
16    Cx::new(Arc::new(NoopEvalPolicy), Arc::new(DefaultFactory))
17}
18
19/// An eager evaluation context: the eager eval policy over the default factory.
20///
21/// Use for tests that evaluate forms to completion.
22pub fn eager_cx() -> Cx {
23    Cx::new(Arc::new(EagerPolicy), Arc::new(DefaultFactory))
24}