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.
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.
14 // Tests of ports and channels on various types
16 struct R {val0: int, val1: u8, val2: char}
18 let (tx, rx) = channel();
19 let r0: R = R {val0: 0, val1: 1u8, val2: '2'};
23 assert_eq!(r1.val0, 0);
24 assert_eq!(r1.val1, 1u8);
25 assert_eq!(r1.val2, '2');
29 let (tx, rx) = channel();
30 let v0: Vec<int> = vec!(0, 1, 2);
33 assert_eq!(*v1.get(0), 0);
34 assert_eq!(*v1.get(1), 1);
35 assert_eq!(*v1.get(2), 2);
39 let (tx, rx) = channel();
43 assert_eq!(s1[0], 't' as u8);
44 assert_eq!(s1[1], 'e' as u8);
45 assert_eq!(s1[2], 's' as u8);
46 assert_eq!(s1[3], 't' as u8);
57 fn eq(&self, other: &t) -> bool {
67 tag2(e0b) => e0a == e0b,
71 tag3(e0a, e1a, e2a) => {
73 tag3(e0b, e1b, e2b) =>
74 e0a == e0b && e1a == e1b && e2a == e2b,
80 fn ne(&self, other: &t) -> bool { !(*self).eq(other) }
84 let (tx, rx) = channel();
87 tx.send(tag3(10, 11u8, 'A'));
92 assert_eq!(t1, tag2(10));
94 assert_eq!(t1, tag3(10, 11u8, 'A'));
98 let (tx1, rx1) = channel();
99 let (tx2, rx2) = channel();
101 let tx2 = rx1.recv();
102 // Does the transmitted channel still work?