Sha256: 23e997ade3517b32fa3a33a783f7b0dc6ef9a86090079ff2dc9dbcb93415fecb

Contents?: true

Size: 653 Bytes

Versions: 8

Compression:

Stored size: 653 Bytes

Contents

use async_timer::Interval;
use tokio_1 as tokio;

use std::time;

#[tokio::test]
async fn test_interval() {
    let mut interval = Interval::platform_new(time::Duration::from_secs(1));

    let before = time::SystemTime::now();
    interval.wait().await;
    let after = time::SystemTime::now();
    let diff = after.duration_since(before).unwrap();

    assert!(diff.as_millis() >= 750 && diff.as_millis() <= 1_250);

    let before = time::SystemTime::now();
    interval.wait().await;
    let after = time::SystemTime::now();
    let diff = after.duration_since(before).unwrap();

    assert!(diff.as_millis() >= 750 && diff.as_millis() <= 1_250);
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wasmtime-20.0.0 ./ext/cargo-vendor/async-timer-1.0.0-beta.11/tests/interval.rs
wasmtime-18.0.3 ./ext/cargo-vendor/async-timer-1.0.0-beta.11/tests/interval.rs
wasmtime-17.0.1 ./ext/cargo-vendor/async-timer-1.0.0-beta.11/tests/interval.rs
wasmtime-17.0.0 ./ext/cargo-vendor/async-timer-1.0.0-beta.11/tests/interval.rs
wasmtime-16.0.0 ./ext/cargo-vendor/async-timer-1.0.0-beta.11/tests/interval.rs
wasmtime-15.0.1 ./ext/cargo-vendor/async-timer-1.0.0-beta.11/tests/interval.rs
wasmtime-15.0.0 ./ext/cargo-vendor/async-timer-1.0.0-beta.11/tests/interval.rs
wasmtime-14.0.4 ./ext/cargo-vendor/async-timer-1.0.0-beta.11/tests/interval.rs