Struct Tester

Source
pub struct Tester { /* private fields */ }
Expand description

Builder pattern to prepare an EndBASIC machine for testing purposes.

Implementations§

Source§

impl Tester

Source

pub fn empty() -> Self

Creates a new tester with an empty Machine.

Source

pub fn add_callable(self, callable: Rc<dyn Callable>) -> Self

Registers the given builtin command into the machine, which must not yet be registered.

Source

pub fn add_input_chars(self, golden_in: &str) -> Self

Adds the golden_in characters as console input.

Source

pub fn add_input_keys(self, keys: &[Key]) -> Self

Adds a bunch of keys as golden input to the console.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_var(self, name: &str, value: Value) -> Self

Sets a variable to an initial value.

Source

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.

Source

pub fn write_file(self, name: &str, content: &str) -> Self

Creates or overwrites a file in the storage medium.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for Tester

Source§

fn default() -> Self

Creates a new tester for a fully-equipped (interactive) machine.

Auto Trait Implementations§

§

impl Freeze for Tester

§

impl !RefUnwindSafe for Tester

§

impl !Send for Tester

§

impl !Sync for Tester

§

impl !Unpin for Tester

§

impl !UnwindSafe for Tester

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V