pub trait CalculatorDriver {
// Required methods
fn enter_expression(&mut self, expr: &str) -> CalcResult<()>;
fn get_result(&self) -> String;
fn get_input(&self) -> String;
fn clear(&mut self);
fn get_history(&self) -> Vec<HistoryItem>;
fn get_jidoka_status(&self) -> Vec<String>;
}Expand description
Abstract driver trait for calculator interactions
This trait defines the interface that both TUI and WASM drivers implement, enabling unified test specifications that work on any platform.
§Example
ⓘ
// The abstract test specification
async fn verify_calculation<D: CalculatorDriver>(driver: &mut D) {
driver.enter_expression("10 * (5 + 5)").await;
assert_eq!(driver.get_result().await, "100");
}
// TUI test
#[test]
fn test_tui() {
let mut driver = TuiDriver::new();
block_on(verify_calculation(&mut driver));
}
// WASM test
#[wasm_bindgen_test]
async fn test_wasm() {
let mut driver = WasmDriver::new().await;
verify_calculation(&mut driver).await;
}Required Methods§
Sourcefn enter_expression(&mut self, expr: &str) -> CalcResult<()>
fn enter_expression(&mut self, expr: &str) -> CalcResult<()>
Enters an expression into the calculator
Sourcefn get_result(&self) -> String
fn get_result(&self) -> String
Gets the current result display
Sourcefn get_history(&self) -> Vec<HistoryItem>
fn get_history(&self) -> Vec<HistoryItem>
Gets history entries (newest first)
Sourcefn get_jidoka_status(&self) -> Vec<String>
fn get_jidoka_status(&self) -> Vec<String>
Gets Anomaly status messages
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".