Skip to main content

Tester

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_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 send_break(self) -> Self

Sends a break signal to the machine.

Source

pub fn set_var<S: Into<String>, V: Into<ConstantDatum>>( self, name: S, value: V, ) -> Self

Sets a global 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 continue_from_here(&self) -> TesterContinuation<'_>

Creates a continuation from the current tester state without running any code.

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 Clone for Tester

Source§

fn clone(&self) -> Tester

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
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 !UnsafeUnpin 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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