summaryrefslogtreecommitdiffstats
path: root/third_party/rust/futures/tests/select_ok.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/futures/tests/select_ok.rs')
-rw-r--r--third_party/rust/futures/tests/select_ok.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/third_party/rust/futures/tests/select_ok.rs b/third_party/rust/futures/tests/select_ok.rs
new file mode 100644
index 0000000000..db88a95c7a
--- /dev/null
+++ b/third_party/rust/futures/tests/select_ok.rs
@@ -0,0 +1,39 @@
+use futures::executor::block_on;
+use futures::future::{err, ok, select_ok};
+
+#[test]
+fn ignore_err() {
+ let v = vec![
+ err(1),
+ err(2),
+ ok(3),
+ ok(4),
+ ];
+
+ let (i, v) = block_on(select_ok(v)).ok().unwrap();
+ assert_eq!(i, 3);
+
+ assert_eq!(v.len(), 1);
+
+ let (i, v) = block_on(select_ok(v)).ok().unwrap();
+ assert_eq!(i, 4);
+
+ assert!(v.is_empty());
+}
+
+#[test]
+fn last_err() {
+ let v = vec![
+ ok(1),
+ err(2),
+ err(3),
+ ];
+
+ let (i, v) = block_on(select_ok(v)).ok().unwrap();
+ assert_eq!(i, 1);
+
+ assert_eq!(v.len(), 2);
+
+ let i = block_on(select_ok(v)).err().unwrap();
+ assert_eq!(i, 3);
+}