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