2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2015-03-22 15:13:15 -05:00
|
|
|
|
2014-12-23 13:53:35 -06:00
|
|
|
use std::sync::mpsc::channel;
|
2014-12-22 11:04:23 -06:00
|
|
|
|
2013-02-01 21:43:17 -06:00
|
|
|
pub fn main() { test00(); }
|
2010-07-19 19:33:50 -05:00
|
|
|
|
2011-04-19 15:35:49 -05:00
|
|
|
fn test00() {
|
2015-03-25 19:06:52 -05:00
|
|
|
let _r: isize = 0;
|
|
|
|
let mut sum: isize = 0;
|
2014-03-09 16:58:32 -05:00
|
|
|
let (tx, rx) = channel();
|
2015-03-25 19:06:52 -05:00
|
|
|
let number_of_messages: isize = 1000;
|
|
|
|
let mut i: isize = 0;
|
2014-12-23 13:53:35 -06:00
|
|
|
while i < number_of_messages { tx.send(i + 0).unwrap(); i += 1; }
|
2010-07-19 19:33:50 -05:00
|
|
|
i = 0;
|
2014-12-23 13:53:35 -06:00
|
|
|
while i < number_of_messages { sum += rx.recv().unwrap(); i += 1; }
|
2013-05-18 21:02:45 -05:00
|
|
|
assert_eq!(sum, number_of_messages * (number_of_messages - 1) / 2);
|
2011-08-19 17:16:48 -05:00
|
|
|
}
|