2012-09-19 15:59:44 -05:00
|
|
|
// xfail-fast
|
2012-09-18 17:52:21 -05:00
|
|
|
#[legacy_modes];
|
|
|
|
|
2012-09-11 19:46:20 -05:00
|
|
|
extern mod std;
|
2011-12-15 20:44:13 -06:00
|
|
|
|
2012-09-05 14:32:05 -05:00
|
|
|
use comm::Chan;
|
|
|
|
use comm::send;
|
2011-12-15 20:44:13 -06:00
|
|
|
|
|
|
|
fn main() { test05(); }
|
|
|
|
|
|
|
|
type pair<A,B> = { a: A, b: B };
|
|
|
|
|
2012-09-07 16:52:28 -05:00
|
|
|
fn make_generic_record<A: Copy, B: Copy>(a: A, b: B) -> pair<A,B> {
|
2012-08-01 19:30:05 -05:00
|
|
|
return {a: a, b: b};
|
2011-12-15 20:44:13 -06:00
|
|
|
}
|
|
|
|
|
2012-09-23 06:39:27 -05:00
|
|
|
fn test05_start(&&f: fn~(&&v: float, &&v: ~str) -> pair<float, ~str>) {
|
2012-07-14 00:57:48 -05:00
|
|
|
let p = f(22.22f, ~"Hi");
|
2012-12-05 18:51:32 -06:00
|
|
|
log(debug, copy p);
|
2011-12-15 20:44:13 -06:00
|
|
|
assert p.a == 22.22f;
|
2012-07-14 00:57:48 -05:00
|
|
|
assert p.b == ~"Hi";
|
2011-12-15 20:44:13 -06:00
|
|
|
|
2012-07-14 00:57:48 -05:00
|
|
|
let q = f(44.44f, ~"Ho");
|
2012-12-05 18:51:32 -06:00
|
|
|
log(debug, copy q);
|
2011-12-15 20:44:13 -06:00
|
|
|
assert q.a == 44.44f;
|
2012-07-14 00:57:48 -05:00
|
|
|
assert q.b == ~"Ho";
|
2011-12-15 20:44:13 -06:00
|
|
|
}
|
|
|
|
|
2012-09-07 16:52:28 -05:00
|
|
|
fn spawn<A: Copy, B: Copy>(f: extern fn(fn~(A,B)->pair<A,B>)) {
|
2012-01-11 11:58:05 -06:00
|
|
|
let arg = fn~(a: A, b: B) -> pair<A,B> {
|
2012-08-01 19:30:05 -05:00
|
|
|
return make_generic_record(a, b);
|
2011-12-15 20:44:13 -06:00
|
|
|
};
|
2012-06-30 18:19:07 -05:00
|
|
|
task::spawn(|| f(arg) );
|
2011-12-15 20:44:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test05() {
|
2012-07-14 00:57:48 -05:00
|
|
|
spawn::<float,~str>(test05_start);
|
2011-12-15 20:44:13 -06:00
|
|
|
}
|