diff --git a/src/timer.rs b/src/timer.rs index 3410bc4..5a90d36 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -166,9 +166,12 @@ impl impl Timer { /// Block until the timer has expired - pub fn wait(self) { + pub fn wait(self) -> TimerBuilder { // since the timer is running, _is_expired() will return a value while !self._is_expired() {} + + TimerBuilder::::new() + .set_duration(self.duration.unwrap()) } /// Check whether the timer has expired @@ -256,12 +259,20 @@ mod test { init_start_time(); // WHEN blocking on a timer - Clock::new_timer().set_duration(1.seconds()).start().wait(); + let timer = Clock::new_timer().set_duration(1.seconds()).start().wait(); // THEN the block occurs for _at least_ the given duration unsafe { assert!(Seconds::::try_from(START.unwrap().elapsed()).unwrap() >= 1.seconds()); } + + // WHEN blocking on a timer + timer.start().wait(); + + // THEN the block occurs for _at least_ the given duration + unsafe { + assert!(Seconds::::try_from(START.unwrap().elapsed()).unwrap() >= 2.seconds()); + } } #[test]