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(
17 Arc::new(NoopEvalPolicy),
18 Arc::new(DefaultFactory),
19 crate::HandleSeed::new(0x5445_5354),
20 )
21}
22
23/// An eager evaluation context: the eager eval policy over the default factory.
24///
25/// Use for tests that evaluate forms to completion.
26pub fn eager_cx() -> Cx {
27 Cx::new(
28 Arc::new(EagerPolicy),
29 Arc::new(DefaultFactory),
30 crate::HandleSeed::new(0x5445_5354),
31 )
32}