PageRenderTime 13ms CodeModel.GetById 1ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/run-pass/task-comm-4.rs

http://github.com/jruderman/rust
Rust | 44 lines | 42 code | 2 blank | 0 comment | 1 complexity | c1938dd65537bf416d58bf692f6f6662 MD5 | raw file
 1use std;
 2import pipes;
 3import pipes::send;
 4
 5fn main() { test00(); }
 6
 7fn test00() {
 8    let mut r: int = 0;
 9    let mut sum: int = 0;
10    let (c, p) = pipes::stream();
11    c.send(1);
12    c.send(2);
13    c.send(3);
14    c.send(4);
15    r = p.recv();
16    sum += r;
17    log(debug, r);
18    r = p.recv();
19    sum += r;
20    log(debug, r);
21    r = p.recv();
22    sum += r;
23    log(debug, r);
24    r = p.recv();
25    sum += r;
26    log(debug, r);
27    c.send(5);
28    c.send(6);
29    c.send(7);
30    c.send(8);
31    r = p.recv();
32    sum += r;
33    log(debug, r);
34    r = p.recv();
35    sum += r;
36    log(debug, r);
37    r = p.recv();
38    sum += r;
39    log(debug, r);
40    r = p.recv();
41    sum += r;
42    log(debug, r);
43    assert (sum == 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8);
44}