Skip to content

Commit 34283c6

Browse files
committed
add test that requires capturing generic descriptors
1 parent 4465c1a commit 34283c6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
type pair<A,B> = { a: A, b: B };
10+
11+
fn make_generic_record<copy A,copy B>(a: A, b: B) -> pair<A,B> {
12+
ret {a: a, b: b};
13+
}
14+
15+
fn test05_start(&&f: sendfn(&&float, &&str) -> pair<float, str>) {
16+
let p = f(22.22f, "Hi");
17+
log p;
18+
assert p.a == 22.22f;
19+
assert p.b == "Hi";
20+
21+
let q = f(44.44f, "Ho");
22+
log q;
23+
assert q.a == 44.44f;
24+
assert q.b == "Ho";
25+
}
26+
27+
fn spawn<copy A, copy B>(f: fn(sendfn(A,B)->pair<A,B>)) {
28+
let arg = sendfn(a: A, b: B) -> pair<A,B> {
29+
ret make_generic_record(a, b);
30+
};
31+
task::spawn(arg, f);
32+
}
33+
34+
fn test05() {
35+
spawn::<float,str>(test05_start);
36+
}

0 commit comments

Comments
 (0)