pub struct TestUniverse { /* private fields */ }Expand description
Test universe for end-to-end VPL program testing.
Combines an Engine with a SimulatedScheduler to enable deterministic,
instant testing of VPL programs that include timer-based streams.
Implementations§
Source§impl TestUniverse
impl TestUniverse
Sourcepub fn from_source(vpl_source: &str) -> Result<Self, String>
pub fn from_source(vpl_source: &str) -> Result<Self, String>
Create a test universe from VPL source code.
Parses the source, creates an engine, and registers any timer streams with the simulated scheduler.
Sourcepub async fn send(&mut self, event: Event) -> Result<(), String>
pub async fn send(&mut self, event: Event) -> Result<(), String>
Send an event into the engine for processing.
Sourcepub async fn send_at_now(&mut self, event_type: &str) -> Result<(), String>
pub async fn send_at_now(&mut self, event_type: &str) -> Result<(), String>
Create and send an event with the given type (no extra fields).
Sourcepub async fn advance(&mut self, duration: Duration) -> Vec<Event>
pub async fn advance(&mut self, duration: Duration) -> Vec<Event>
Advance simulated time and process all timer events that fire.
Returns all output events produced during the advance.
Sourcepub fn drain_output(&mut self) -> Vec<Event>
pub fn drain_output(&mut self) -> Vec<Event>
Drain all currently buffered output events.
Sourcepub const fn engine_mut(&mut self) -> &mut Engine
pub const fn engine_mut(&mut self) -> &mut Engine
Get a mutable reference to the underlying engine.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TestUniverse
impl !RefUnwindSafe for TestUniverse
impl Send for TestUniverse
impl Sync for TestUniverse
impl Unpin for TestUniverse
impl UnsafeUnpin for TestUniverse
impl !UnwindSafe for TestUniverse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more