mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
timer: move tokio-timer into tokio crate (#1674)
A step towards collapsing Tokio sub crates into a single `tokio` crate (#1318). The `timer` implementation is now provided by the main `tokio` crate. The `timer` functionality may still be excluded from the build by skipping the `timer` feature flag.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
use tokio::timer::delay;
|
||||
use tokio_test::block_on;
|
||||
use tokio_timer::delay;
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
#[test]
|
||||
fn async_block() {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#![cfg(feature = "broken")]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use futures::Future;
|
||||
use std::time::{Duration, Instant};
|
||||
use tokio::timer::delay;
|
||||
use tokio_test::clock::MockClock;
|
||||
use tokio_test::task::MockTask;
|
||||
use tokio_test::{assert_not_ready, assert_ready};
|
||||
use tokio_timer::delay;
|
||||
use tokio_test::task;
|
||||
use tokio_test::{assert_pending, assert_ready};
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
#[test]
|
||||
fn clock() {
|
||||
@@ -14,30 +13,13 @@ fn clock() {
|
||||
|
||||
mock.enter(|handle| {
|
||||
let deadline = Instant::now() + Duration::from_secs(1);
|
||||
let mut delay = delay(deadline);
|
||||
let mut delay = task::spawn(delay(deadline));
|
||||
|
||||
assert_not_ready!(delay.poll());
|
||||
assert_pending!(delay.poll());
|
||||
|
||||
handle.advance(Duration::from_secs(2));
|
||||
|
||||
assert_ready!(delay.poll());
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn notify() {
|
||||
let deadline = Instant::now() + Duration::from_secs(1);
|
||||
let mut mock = MockClock::new();
|
||||
let mut task = MockTask::new();
|
||||
|
||||
mock.enter(|handle| {
|
||||
let mut delay = delay(deadline);
|
||||
|
||||
task.enter(|| assert_not_ready!(delay.poll()));
|
||||
|
||||
handle.advance(Duration::from_secs(1));
|
||||
|
||||
assert!(task.is_notified());
|
||||
assert!(delay.is_woken());
|
||||
assert_ready!(delay.poll());
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user