MCPcopy Index your code
hub / github.com/endbasic/endbasic / make_mock_machine

Function make_mock_machine

std/src/gpio/mod.rs:506–514  ·  view source on GitHub ↗

Creates a machine backed by `MockPins` pre-seeded with `reads` and returns both the machine and a handle to inspect the trace afterwards.

(reads: &[(u8, bool)])

Source from the content-addressed store, hash-verified

504 /// Creates a machine backed by `MockPins` pre-seeded with `reads` and returns both the machine
505 /// and a handle to inspect the trace afterwards.
506 fn make_mock_machine(reads: &[(u8, bool)]) -> (crate::Machine, Rc<RefCell<MockPins>>) {
507 let mock_pins = Rc::new(RefCell::new(MockPins::default()));
508 for &(pin, high) in reads {
509 mock_pins.borrow_mut().inject_read(Pin(pin), high);
510 }
511 let pins: Rc<RefCell<dyn Pins>> = mock_pins.clone();
512 let machine = MachineBuilder::default().with_gpio_pins(pins).build();
513 (machine, mock_pins)
514 }
515
516 /// Runs `code` in a machine backed by MockPins pre-seeded with `reads` and asserts that the
517 /// resulting trace equals `expected_trace`.

Callers 1

do_mock_testFunction · 0.85

Calls 4

PinClass · 0.85
inject_readMethod · 0.80
with_gpio_pinsMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected