rust/src/test/run-pass/unique-send-2.rs
Marijn Haverbeke 3b5b93221e Remove some semicolons after block calls
The remaining ones can be removed after the next snapshot. (Or
we can let the next pretty-print pass take care of them.)
2011-10-21 14:24:42 +02:00

27 lines
484 B
Rust

use std;
import std::comm;
import std::task;
import std::uint;
fn child(args: (comm::chan<~uint>, uint)) {
let (c, i) = args;
comm::send(c, ~i);
}
fn main() {
let p = comm::port();
let n = 100u;
let expected = 0u;
uint::range(0u, n) {|i|
task::spawn((comm::chan(p), i), child);
expected += i;
}
let actual = 0u;
uint::range(0u, n) {|_i|
let j = comm::recv(p);
actual += *j;
}
assert expected == actual;
}