mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-19 00:00:09 +02:00
time: adjust tests::time_rt::tickspace (#8318)
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![cfg(feature = "full")]
|
||||
|
||||
use futures_test::task::noop_context;
|
||||
use tokio::runtime::Runtime;
|
||||
use tokio::time::*;
|
||||
use tokio_test::assert_pending;
|
||||
|
||||
use std::sync::mpsc;
|
||||
|
||||
@@ -168,9 +166,14 @@ fn timeout_value() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "test-util")]
|
||||
fn tickspace() {
|
||||
use futures::task::noop_waker_ref;
|
||||
use std::future::Future as _;
|
||||
use std::task::Context;
|
||||
use std::thread;
|
||||
use tokio_test::assert_pending;
|
||||
|
||||
let rt = || {
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
.enable_time()
|
||||
@@ -185,7 +188,9 @@ fn tickspace() {
|
||||
|
||||
let _guard = rt_past.enter();
|
||||
let mut sleep = std::pin::pin!(sleep(Duration::from_millis(1)));
|
||||
assert_pending!(sleep.as_mut().poll(&mut noop_context()));
|
||||
assert_pending!(sleep
|
||||
.as_mut()
|
||||
.poll(&mut Context::from_waker(noop_waker_ref())));
|
||||
|
||||
let deadline = sleep.deadline();
|
||||
rt.block_on(async { sleep.as_mut().reset(deadline + Duration::from_millis(1)) });
|
||||
|
||||
Reference in New Issue
Block a user