]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/task-comm-4.rs
New upstream version 1.19.0+dfsg1
[rustc.git] / src / test / run-pass / task-comm-4.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![allow(dead_assignment)]
12
13 use std::sync::mpsc::channel;
14
15 pub fn main() { test00(); }
16
17 fn test00() {
18 let mut r: isize = 0;
19 let mut sum: isize = 0;
20 let (tx, rx) = channel();
21 tx.send(1).unwrap();
22 tx.send(2).unwrap();
23 tx.send(3).unwrap();
24 tx.send(4).unwrap();
25 r = rx.recv().unwrap();
26 sum += r;
27 println!("{}", r);
28 r = rx.recv().unwrap();
29 sum += r;
30 println!("{}", r);
31 r = rx.recv().unwrap();
32 sum += r;
33 println!("{}", r);
34 r = rx.recv().unwrap();
35 sum += r;
36 println!("{}", r);
37 tx.send(5).unwrap();
38 tx.send(6).unwrap();
39 tx.send(7).unwrap();
40 tx.send(8).unwrap();
41 r = rx.recv().unwrap();
42 sum += r;
43 println!("{}", r);
44 r = rx.recv().unwrap();
45 sum += r;
46 println!("{}", r);
47 r = rx.recv().unwrap();
48 sum += r;
49 println!("{}", r);
50 r = rx.recv().unwrap();
51 sum += r;
52 println!("{}", r);
53 assert_eq!(sum, 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8);
54 }