Skip to content

Commit 5ed3443

Browse files
authored
Merge pull request #9 from kpp/inc_coverage
Increase code coverage
2 parents c7460b2 + 82ff19a commit 5ed3443

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/future.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ pub fn poll_fn<F, T>(f: F) -> impl Future<Output = T>
140140
from_generator(|| {
141141
let mut f = f;
142142
loop {
143-
let poll_result = get_task_context(|context: &mut Context| f(context));
144-
match poll_result {
143+
match get_task_context(|context: &mut Context| f(context)) {
145144
Poll::Pending => yield,
146145
Poll::Ready(value) => return value,
147146
}
@@ -181,14 +180,23 @@ mod tests {
181180
}
182181

183182
#[test]
184-
fn test_and_then() {
183+
fn test_and_then_ok() {
185184
executor::block_on(async {
186185
let future = ready(Ok::<i32, i32>(1));
187186
let new_future = and_then(future, |x| ready(Ok::<i32, i32>(x + 3)));
188187
assert_eq!(new_future.await, Ok(4));
189188
});
190189
}
191190

191+
#[test]
192+
fn test_and_then_err() {
193+
executor::block_on(async {
194+
let future = ready(Err::<i32, i32>(1));
195+
let new_future = and_then(future, |x| ready(Ok::<i32, i32>(x + 3)));
196+
assert_eq!(new_future.await, Err(1));
197+
});
198+
}
199+
192200
#[test]
193201
fn test_or_else() {
194202
executor::block_on(async {

0 commit comments

Comments
 (0)