@@ -217,6 +217,40 @@ mod tests {
217217 assert_eq ! ( clock. now( ) , t2) ;
218218 }
219219
220+ #[ tokio:: test]
221+ async fn should_allow_time_to_stand_still ( ) {
222+ let mut coordinator = ClockCoordinator :: new ( ) ;
223+ let clock = coordinator. clock ( ) ;
224+ let t0 = clock. now ( ) ;
225+ let t1 = t0 + Duration :: from_millis ( 5 ) ;
226+ let t2 = t0 + Duration :: from_millis ( 10 ) ;
227+ let mut actor = clock. barrier ( ) ;
228+
229+ let run_future = coordinator. run ( ) ;
230+ pin ! ( run_future) ;
231+
232+ // The actor waits until t1, then cancels that wait,
233+ // before the coordinator has a chance to run
234+ {
235+ let wait1 = actor. wait_until ( t1) ;
236+ assert_eq ! ( poll!( wait1) , Poll :: Pending ) ;
237+ }
238+
239+ // The actor should be able to wait until t1 without issue,
240+ // even though it has already cancelled a wait for t1.
241+ let mut wait1 = actor. wait_until ( t1) ;
242+ assert_eq ! ( poll!( & mut wait1) , Poll :: Pending ) ;
243+ assert_eq ! ( poll!( & mut run_future) , Poll :: Pending ) ;
244+ assert_eq ! ( poll!( & mut wait1) , Poll :: Ready ( ( ) ) ) ;
245+ drop ( wait1) ;
246+
247+ // Test waiting for another few moments just for good measure
248+ let mut wait2 = actor. wait_until ( t2) ;
249+ assert_eq ! ( poll!( & mut wait2) , Poll :: Pending ) ;
250+ assert_eq ! ( poll!( & mut run_future) , Poll :: Pending ) ;
251+ assert_eq ! ( poll!( & mut wait2) , Poll :: Ready ( ( ) ) ) ;
252+ }
253+
220254 #[ tokio:: test]
221255 async fn should_allow_waiting_forever ( ) {
222256 let mut coordinator = ClockCoordinator :: new ( ) ;
0 commit comments