blob: fbb0cec73c914efcadc023fbb1706c9d73f0c3fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import core::*;
use std;
import comm;
#[test]
fn create_port_and_chan() { let p = comm::port::<int>(); comm::chan(p); }
#[test]
fn send_int() {
let p = comm::port::<int>();
let c = comm::chan(p);
comm::send(c, 22);
}
#[test]
fn send_recv_fn() {
let p = comm::port::<int>();
let c = comm::chan::<int>(p);
comm::send(c, 42);
assert (comm::recv(p) == 42);
}
#[test]
fn send_recv_fn_infer() {
let p = comm::port();
let c = comm::chan(p);
comm::send(c, 42);
assert (comm::recv(p) == 42);
}
#[test]
fn chan_chan_infer() {
let p = comm::port(), p2 = comm::port::<int>();
let c = comm::chan(p);
comm::send(c, comm::chan(p2));
comm::recv(p);
}
#[test]
fn chan_chan() {
let p = comm::port::<comm::chan<int>>(), p2 = comm::port::<int>();
let c = comm::chan(p);
comm::send(c, comm::chan(p2));
comm::recv(p);
}
|