Skip to content

Commit 4465c1a

Browse files
committed
first test of sendable fns (passes)
1 parent 21cc0c6 commit 4465c1a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use std;
2+
3+
import std::comm;
4+
import std::comm::chan;
5+
import std::comm::send;
6+
7+
fn main() { test05(); }
8+
9+
fn test05_start(&&f: sendfn(int)) {
10+
f(22);
11+
}
12+
13+
fn test05() {
14+
let three = ~3;
15+
let fn_to_send = sendfn(n: int) {
16+
log_err *three + n; // will copy x into the closure
17+
assert(*three == 3);
18+
};
19+
task::spawn(fn_to_send, test05_start);
20+
}

0 commit comments

Comments
 (0)