mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
time: check for overflow in Interval::poll_tick (#6487)
This commit is contained in:
@@ -6,7 +6,7 @@ use std::task::{Context, Poll};
|
||||
|
||||
use futures::{Stream, StreamExt};
|
||||
use tokio::time::{self, Duration, Instant, Interval, MissedTickBehavior};
|
||||
use tokio_test::{assert_pending, assert_ready_eq, task};
|
||||
use tokio_test::{assert_pending, assert_ready, assert_ready_eq, task};
|
||||
|
||||
// Takes the `Interval` task, `start` variable, and optional time deltas
|
||||
// For each time delta, it polls the `Interval` and asserts that the result is
|
||||
@@ -469,3 +469,9 @@ async fn stream_with_interval_poll_tick_no_waking() {
|
||||
// task when returning `Poll::Ready`.
|
||||
assert_eq!(items, vec![]);
|
||||
}
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn interval_doesnt_panic_max_duration_when_polling() {
|
||||
let mut timer = task::spawn(time::interval(Duration::MAX));
|
||||
assert_ready!(timer.enter(|cx, mut timer| timer.poll_tick(cx)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user