]> git.proxmox.com Git - rustc.git/blame - src/test/ui/run-pass/threads-sendsync/task-comm-4.rs
New upstream version 1.30.0+dfsg1
[rustc.git] / src / test / ui / run-pass / threads-sendsync / task-comm-4.rs
CommitLineData
223e47cc
LB
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
b7449926 11// run-pass
1a4d82fc
JJ
12
13use std::sync::mpsc::channel;
970d7e83 14
223e47cc
LB
15pub fn main() { test00(); }
16
17fn test00() {
c34b1796
AL
18 let mut r: isize = 0;
19 let mut sum: isize = 0;
1a4d82fc
JJ
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();
223e47cc 26 sum += r;
1a4d82fc
JJ
27 println!("{}", r);
28 r = rx.recv().unwrap();
223e47cc 29 sum += r;
1a4d82fc
JJ
30 println!("{}", r);
31 r = rx.recv().unwrap();
223e47cc 32 sum += r;
1a4d82fc
JJ
33 println!("{}", r);
34 r = rx.recv().unwrap();
223e47cc 35 sum += r;
1a4d82fc
JJ
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();
223e47cc 42 sum += r;
1a4d82fc
JJ
43 println!("{}", r);
44 r = rx.recv().unwrap();
223e47cc 45 sum += r;
1a4d82fc
JJ
46 println!("{}", r);
47 r = rx.recv().unwrap();
223e47cc 48 sum += r;
1a4d82fc
JJ
49 println!("{}", r);
50 r = rx.recv().unwrap();
223e47cc 51 sum += r;
1a4d82fc 52 println!("{}", r);
970d7e83 53 assert_eq!(sum, 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8);
223e47cc 54}