Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Aug 3, 2018
1 parent 1652811 commit 2b22db2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
60 changes: 40 additions & 20 deletions test/test_poll_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ pub fn test_poll_channel_edge() {
.unwrap();

// Wait, but nothing should happen
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);

// Push the value
tx.send("hello").unwrap();

// Polling will contain the event
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(1, num);

Expand All @@ -33,23 +35,26 @@ pub fn test_poll_channel_edge() {
assert_eq!(event.readiness(), Ready::readable());

// Poll again and there should be no events
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);

// Read the value
assert_eq!("hello", rx.try_recv().unwrap());

// Poll again, nothing
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);

// Push a value
tx.send("goodbye").unwrap();

// Have an event
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(1, num);

Expand All @@ -63,7 +68,8 @@ pub fn test_poll_channel_edge() {
// Drop the sender half
drop(tx);

let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(1, num);

Expand Down Expand Up @@ -91,15 +97,17 @@ pub fn test_poll_channel_oneshot() {
).unwrap();

// Wait, but nothing should happen
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);

// Push the value
tx.send("hello").unwrap();

// Polling will contain the event
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(1, num);

Expand All @@ -108,23 +116,26 @@ pub fn test_poll_channel_oneshot() {
assert_eq!(event.readiness(), Ready::readable());

// Poll again and there should be no events
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);

// Read the value
assert_eq!("hello", rx.try_recv().unwrap());

// Poll again, nothing
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);

// Push a value
tx.send("goodbye").unwrap();

// Poll again, nothing
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);

Expand All @@ -138,7 +149,8 @@ pub fn test_poll_channel_oneshot() {
).unwrap();

// Have an event
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(1, num);

Expand All @@ -158,7 +170,8 @@ pub fn test_poll_channel_oneshot() {
).unwrap();

// Have an event
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);

Expand All @@ -170,7 +183,8 @@ pub fn test_poll_channel_oneshot() {
).unwrap();

// Have an event
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);
}
Expand All @@ -185,7 +199,8 @@ pub fn test_poll_channel_level() {
.unwrap();

// Wait, but nothing should happen
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);

Expand All @@ -194,7 +209,8 @@ pub fn test_poll_channel_level() {

// Polling will contain the event
for i in 0..5 {
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert!(1 == num, "actually got {} on iteration {}", num, i);

Expand All @@ -207,7 +223,8 @@ pub fn test_poll_channel_level() {
assert_eq!("hello", rx.try_recv().unwrap());

// Wait, but nothing should happen
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);
}
Expand All @@ -222,15 +239,17 @@ pub fn test_poll_channel_writable() {
.unwrap();

// Wait, but nothing should happen
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);

// Push the value
tx.send("hello").unwrap();

// Wait, but nothing should happen
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);
}
Expand All @@ -251,7 +270,8 @@ pub fn test_dropping_receive_before_poll() {
drop(rx);

// Wait, but nothing should happen
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(0, num);
}
Expand Down
6 changes: 4 additions & 2 deletions test/test_timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ fn test_edge_without_polling() {
assert!(is_about(400, ms), "actual={:?}", ms);

let ms = elapsed(|| {
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(num, 0);
});
Expand Down Expand Up @@ -229,7 +230,8 @@ fn test_edge_oneshot_triggered() {
assert!(is_about(200, ms), "actual={:?}", ms);

let ms = elapsed(|| {
let num = poll.poll(&mut events, Some(Duration::from_millis(300)))
let num = poll
.poll(&mut events, Some(Duration::from_millis(300)))
.unwrap();
assert_eq!(num, 0);
});
Expand Down

0 comments on commit 2b22db2

Please sign in to comment.