pub struct Tester { /* private fields */ }Expand description
Builder pattern to prepare an EndBASIC machine for testing purposes.
Implementations§
Source§impl Tester
impl Tester
Sourcepub fn add_callable(self, callable: Rc<dyn Callable>) -> Self
pub fn add_callable(self, callable: Rc<dyn Callable>) -> Self
Registers the given builtin command into the machine, which must not yet be registered.
Sourcepub fn add_input_chars(self, golden_in: &str) -> Self
pub fn add_input_chars(self, golden_in: &str) -> Self
Adds the golden_in characters as console input.
Sourcepub fn add_input_keys(self, keys: &[Key]) -> Self
pub fn add_input_keys(self, keys: &[Key]) -> Self
Adds a bunch of keys as golden input to the console.
Sourcepub fn get_console(&self) -> Rc<RefCell<MockConsole>>
pub fn get_console(&self) -> Rc<RefCell<MockConsole>>
Gets the mock console from the tester.
This method should generally not be used. Its primary utility is to hook externally-instantiated commands into the testing features.
Sourcepub fn get_program(&self) -> Rc<RefCell<RecordedProgram>>
pub fn get_program(&self) -> Rc<RefCell<RecordedProgram>>
Gets the recorded program from the tester.
This method should generally not be used. Its primary utility is to hook externally-instantiated commands into the testing features.
Sourcepub fn get_storage(&self) -> Rc<RefCell<Storage>>
pub fn get_storage(&self) -> Rc<RefCell<Storage>>
Gets the storage subsystem from the tester.
This method should generally not be used. Its primary utility is to hook externally-instantiated commands into the testing features.
Sourcepub fn send_break(self) -> Self
pub fn send_break(self) -> Self
Sends a break signal to the machine.
Sourcepub fn set_var<S: Into<String>, V: Into<ConstantDatum>>(
self,
name: S,
value: V,
) -> Self
pub fn set_var<S: Into<String>, V: Into<ConstantDatum>>( self, name: S, value: V, ) -> Self
Sets a global variable to an initial value.
Sourcepub fn set_program(self, name: Option<&str>, text: &str) -> Self
pub fn set_program(self, name: Option<&str>, text: &str) -> Self
Sets the initial name of the recorded program to name (if any) and its contents to text.
Can only be called once and text must not be empty.
Sourcepub fn write_file(self, name: &str, content: &str) -> Self
pub fn write_file(self, name: &str, content: &str) -> Self
Creates or overwrites a file in the storage medium.
Sourcepub fn run<S: Into<String>>(&mut self, script: S) -> Checker<'_>
pub fn run<S: Into<String>>(&mut self, script: S) -> Checker<'_>
Runs script in the configured machine and returns a Checker object to validate
expectations about the execution.
Sourcepub fn continue_from_here(&self) -> TesterContinuation<'_>
pub fn continue_from_here(&self) -> TesterContinuation<'_>
Creates a continuation from the current tester state without running any code.
Sourcepub fn run_n(&mut self, scripts: &[&str]) -> Checker<'_>
pub fn run_n(&mut self, scripts: &[&str]) -> Checker<'_>
Runs scripts in the configured machine and returns a Checker object to validate
expectations about the execution.
The first entry in scripts to fail aborts execution and allows checking the result
of that specific invocation.
This is useful when compared to run because Machine::exec compiles the script as one
unit and thus compilation errors may prevent validating other operations later on.