PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/jruderman/rust
Rust | 16 lines | 14 code | 2 blank | 0 comment | 3 complexity | e0dc3256d6b358837c216ce02c60488b MD5 | raw file
 1use std;
 2import pipes;
 3
 4fn main() { test00(); }
 5
 6fn test00() {
 7    let r: int = 0;
 8    let mut sum: int = 0;
 9    let (c, p) = pipes::stream();
10    let number_of_messages: int = 1000;
11    let mut i: int = 0;
12    while i < number_of_messages { c.send(i + 0); i += 1; }
13    i = 0;
14    while i < number_of_messages { sum += p.recv(); i += 1; }
15    assert (sum == number_of_messages * (number_of_messages - 1) / 2);
16}