Skip to content

Commit

Permalink
Merge pull request #9 from kpp/inc_coverage
Browse files Browse the repository at this point in the history
Increase code coverage
  • Loading branch information
kpp committed Jul 1, 2019
2 parents c7460b2 + 82ff19a commit 5ed3443
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ pub fn poll_fn<F, T>(f: F) -> impl Future<Output = T>
from_generator(|| {
let mut f = f;
loop {
let poll_result = get_task_context(|context: &mut Context| f(context));
match poll_result {
match get_task_context(|context: &mut Context| f(context)) {
Poll::Pending => yield,
Poll::Ready(value) => return value,
}
Expand Down Expand Up @@ -181,14 +180,23 @@ mod tests {
}

#[test]
fn test_and_then() {
fn test_and_then_ok() {
executor::block_on(async {
let future = ready(Ok::<i32, i32>(1));
let new_future = and_then(future, |x| ready(Ok::<i32, i32>(x + 3)));
assert_eq!(new_future.await, Ok(4));
});
}

#[test]
fn test_and_then_err() {
executor::block_on(async {
let future = ready(Err::<i32, i32>(1));
let new_future = and_then(future, |x| ready(Ok::<i32, i32>(x + 3)));
assert_eq!(new_future.await, Err(1));
});
}

#[test]
fn test_or_else() {
executor::block_on(async {
Expand Down

0 comments on commit 5ed3443

Please sign in to comment.