()
| 186 | |
| 187 | #[test] |
| 188 | fn test_break_stops_after_upcall() { |
| 189 | let (tx, rx) = async_channel::unbounded(); |
| 190 | let break_tx = tx.clone(); |
| 191 | let datetime = Rc::from(MockDateTime::default()); |
| 192 | datetime.set_sleep_fn(Box::new( |
| 193 | move |_d: Duration| -> futures_lite::future::BoxedLocal<Result<(), String>> { |
| 194 | let break_tx = break_tx.clone(); |
| 195 | async move { |
| 196 | break_tx.send(Signal::Break).await.unwrap(); |
| 197 | Ok(()) |
| 198 | } |
| 199 | .boxed_local() |
| 200 | }, |
| 201 | )); |
| 202 | |
| 203 | let mut machine = MachineBuilder::default() |
| 204 | .with_signals_chan((tx.clone(), rx)) |
| 205 | .with_datetime(datetime) |
| 206 | .build(); |
| 207 | machine.compile(&mut "DO: SLEEP 0: LOOP".as_bytes()).unwrap(); |
| 208 | |
| 209 | match block_on(machine.exec()) { |
| 210 | Err(Error::Break) => (), |
| 211 | r => panic!("Expected Break but got {:?}", r), |
| 212 | } |
| 213 | assert_eq!(0, tx.len()); |
| 214 | } |
| 215 | |
| 216 | #[test] |
| 217 | fn test_yielder_called_on_stop_reason_yield() { |
nothing calls this directly
no test coverage detected