summaryrefslogtreecommitdiffstats
path: root/third_party/rust/tokio-timer/tests/interval.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/tokio-timer/tests/interval.rs')
-rw-r--r--third_party/rust/tokio-timer/tests/interval.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/third_party/rust/tokio-timer/tests/interval.rs b/third_party/rust/tokio-timer/tests/interval.rs
new file mode 100644
index 0000000000..27828fc83a
--- /dev/null
+++ b/third_party/rust/tokio-timer/tests/interval.rs
@@ -0,0 +1,46 @@
+extern crate futures;
+extern crate tokio_executor;
+extern crate tokio_timer;
+
+#[macro_use]
+mod support;
+use support::*;
+
+use tokio_timer::*;
+
+use futures::Stream;
+
+#[test]
+#[should_panic]
+fn interval_zero_duration() {
+ mocked(|_, time| {
+ let _ = Interval::new(time.now(), ms(0));
+ });
+}
+
+#[test]
+fn usage() {
+ mocked(|timer, time| {
+ let start = time.now();
+ let mut int = Interval::new(start, ms(300));
+
+ assert_ready_eq!(int, Some(start));
+ assert_not_ready!(int);
+
+ advance(timer, ms(100));
+ assert_not_ready!(int);
+
+ advance(timer, ms(200));
+ assert_ready_eq!(int, Some(start + ms(300)));
+ assert_not_ready!(int);
+
+ advance(timer, ms(400));
+ assert_ready_eq!(int, Some(start + ms(600)));
+ assert_not_ready!(int);
+
+ advance(timer, ms(500));
+ assert_ready_eq!(int, Some(start + ms(900)));
+ assert_ready_eq!(int, Some(start + ms(1200)));
+ assert_not_ready!(int);
+ });
+}