extern crate taskpipe; use std::sync::mpsc::{Receiver,Sender}; #[test] fn it_inputs_transforms_and_joins_to_main_all_items() { let result = taskpipe::input(|tx: Sender| { for c in "0123456789abcd".chars() { tx.send(c); } }).input(|tx: Sender| { tx.send('f'); }).input(|tx: Sender| { tx.send('e'); }).pipe(|rx: Receiver, tx: Sender| { for c in rx.iter() { match c.to_digit(16) { Some(u) => tx.send(u), None => continue }; } }).pipe(|rx: Receiver, tx: Sender| { for c in rx.iter() { if c % 2 == 0 { tx.send(true); } else { tx.send(false); } } }).end(|rx: Receiver| { let mut count = 0; for c in rx.iter() { count = count + 1; } count }).join(); match result { Ok(count) => assert_eq!(count, 16), Err(_) => panic!("Thread did not exit successfully!") } }