Skip to main content

sim_kernel/
testing.rs

1//! Shared test-context constructors.
2//!
3//! Almost every crate's test module hand-rolled the same `fn cx() -> Cx`. These
4//! are the two canonical shapes that duplication collapsed to (OVERLAP6.16);
5//! a test helper routes here with `use sim_kernel::testing::bare_cx as cx;`.
6
7use std::sync::Arc;
8
9use crate::{Cx, DefaultFactory, EagerPolicy, NoopEvalPolicy};
10
11/// A bare evaluation context: the no-op eval policy over the default factory.
12///
13/// Use for tests that exercise structure without driving evaluation.
14pub fn bare_cx() -> Cx {
15    Cx::new(Arc::new(NoopEvalPolicy), Arc::new(DefaultFactory))
16}
17
18/// An eager evaluation context: the eager eval policy over the default factory.
19///
20/// Use for tests that evaluate forms to completion.
21pub fn eager_cx() -> Cx {
22    Cx::new(Arc::new(EagerPolicy), Arc::new(DefaultFactory))
23}