summaryrefslogtreecommitdiffstats
path: root/third_party/rust/futures-0.1.31/tests/select_all.rs
blob: 7780aa306d8f9bb2555e7006ecaa5a73a08b19e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
extern crate futures;

use futures::prelude::*;
use futures::future::{ok, select_all, err};

#[test]
fn smoke() {
    let v = vec![
        ok(1),
        err(2),
        ok(3),
    ];

    let (i, idx, v) = select_all(v).wait().ok().unwrap();
    assert_eq!(i, 1);
    assert_eq!(idx, 0);

    let (i, idx, v) = select_all(v).wait().err().unwrap();
    assert_eq!(i, 2);
    assert_eq!(idx, 0);

    let (i, idx, v) = select_all(v).wait().ok().unwrap();
    assert_eq!(i, 3);
    assert_eq!(idx, 0);

    assert!(v.is_empty());
}