Struct endbasic_std::testutils::Tester
source · [−]pub struct Tester { /* private fields */ }Expand description
Builder pattern to prepare an EndBASIC machine for testing purposes.
Implementations
sourceimpl Tester
impl Tester
sourcepub fn add_command(self, command: Rc<dyn Command>) -> Self
pub fn add_command(self, command: Rc<dyn Command>) -> Self
Registers the given builtin command into the machine, which must not yet be registered.
sourcepub fn add_function(self, function: Rc<dyn Function>) -> Self
pub fn add_function(self, function: Rc<dyn Function>) -> Self
Registers the given builtin function 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_machine(&mut self) -> &mut Machine
pub fn get_machine(&mut self) -> &mut Machine
Returns a mutable reference to the machine inside the tester.
This method should generally not be used, except to run native methods that have side-effects on the machine that we’d like to validate later.
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 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.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Tester
impl !Send for Tester
impl !Sync for Tester
impl Unpin for Tester
impl !UnwindSafe for Tester
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more