Skip to content

Commit 7b77f53

Browse files
committed
Add more tests for future::and_then
1 parent c7460b2 commit 7b77f53

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/future.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,23 @@ mod tests {
181181
}
182182

183183
#[test]
184-
fn test_and_then() {
184+
fn test_and_then_ok() {
185185
executor::block_on(async {
186186
let future = ready(Ok::<i32, i32>(1));
187187
let new_future = and_then(future, |x| ready(Ok::<i32, i32>(x + 3)));
188188
assert_eq!(new_future.await, Ok(4));
189189
});
190190
}
191191

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

0 commit comments

Comments
 (0)