From 9f84f88276a04c42340e99e6d9503d49780eb5e7 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 4 Jan 2012 21:14:53 -0800 Subject: [PATCH] port over the tests to use the new API --- src/compiletest/compiletest.rs | 16 +++++----- src/compiletest/procsrv.rs | 15 ++++----- src/test/run-pass/basic-1.rs | 5 +-- src/test/run-pass/basic-2.rs | 8 +++-- src/test/run-pass/basic.rs | 5 +-- src/test/run-pass/binops.rs | 6 ++-- src/test/run-pass/chan-leak.rs | 3 +- src/test/run-pass/child-outlives-parent.rs | 2 +- src/test/run-pass/comm.rs | 3 +- src/test/run-pass/hashmap-memory.rs | 8 ++--- src/test/run-pass/issue-507.rs | 5 +-- src/test/run-pass/issue-687.rs | 9 +++--- src/test/run-pass/issue-783.rs | 7 ++-- src/test/run-pass/ivec-tag.rs | 3 +- src/test/run-pass/join.rs | 4 +-- src/test/run-pass/lazychan.rs | 5 +-- src/test/run-pass/linked-failure.rs | 8 ++--- src/test/run-pass/lots-a-fail.rs | 8 ++--- src/test/run-pass/many.rs | 9 +++--- src/test/run-pass/morestack5.rs | 2 +- src/test/run-pass/morestack6.rs | 7 ++-- src/test/run-pass/send-iloop.rs | 8 ++--- src/test/run-pass/sendfn-generic-fn.rs | 2 +- src/test/run-pass/sendfn-spawn-with-fn-arg.rs | 4 ++- src/test/run-pass/spawn-fn.rs | 12 +++---- src/test/run-pass/spawn-module-qualified.rs | 2 +- src/test/run-pass/spawn-types.rs | 6 ++-- src/test/run-pass/spawn.rs | 5 ++- src/test/run-pass/spawn2.rs | 2 +- src/test/run-pass/task-comm-0.rs | 2 +- src/test/run-pass/task-comm-1.rs | 4 +-- src/test/run-pass/task-comm-10.rs | 3 +- src/test/run-pass/task-comm-11.rs | 3 +- src/test/run-pass/task-comm-12.rs | 2 +- src/test/run-pass/task-comm-13.rs | 6 ++-- src/test/run-pass/task-comm-14.rs | 8 ++--- src/test/run-pass/task-comm-15.rs | 13 +++++--- src/test/run-pass/task-comm-2.rs | 2 +- src/test/run-pass/task-comm-3.rs | 8 ++--- src/test/run-pass/task-comm-7.rs | 32 ++++++++----------- src/test/run-pass/task-comm-8.rs | 32 ++++++++----------- src/test/run-pass/task-comm-9.rs | 9 +++--- src/test/run-pass/task-comm-chan-cleanup4.rs | 7 ++-- src/test/run-pass/task-comm.rs | 16 +++++----- src/test/run-pass/task-killjoin.rs | 8 ++--- src/test/run-pass/task-life-0.rs | 4 ++- src/test/run-pass/terminate-in-initializer.rs | 8 ++--- src/test/run-pass/threads.rs | 2 +- src/test/run-pass/unique-send-2.rs | 6 ++-- src/test/run-pass/unwind-box.rs | 4 +-- src/test/run-pass/unwind-resource.rs | 2 +- src/test/run-pass/unwind-resource2.rs | 4 +-- src/test/run-pass/unwind-unique.rs | 4 +-- src/test/run-pass/yield.rs | 4 +-- src/test/run-pass/yield1.rs | 4 +-- src/test/stdtest/task.rs | 8 ++--- src/test/stdtest/vec.rs | 4 +-- 57 files changed, 202 insertions(+), 186 deletions(-) diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index d720c036d95..1193fa81131 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -193,21 +193,21 @@ fn closure_to_task(cx: cx, configport: port<[u8]>, testfn: fn@()) -> test::joinable { testfn(); let testfile = recv(configport); - - ret task::spawn_joinable( - (cx.config, cx.procsrv.chan, testfile), run_test_task); + let (config, chan) = (cx.config, cx.procsrv.chan); + ret task::spawn_joinable {|| + run_test_task(config, chan, testfile); + }; } -fn run_test_task(args: (common::config, procsrv::reqchan, [u8])) { - - let (config, procsrv_chan, testfile) = args; - +fn run_test_task(config: common::config, + procsrv_chan: procsrv::reqchan, + testfile: [u8]) { test::configure_test_task(); let procsrv = procsrv::from_chan(procsrv_chan); let cx = {config: config, procsrv: procsrv}; - runtest::run(cx, testfile); + runtest::run(cx, copy testfile); } // Local Variables: diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index 39ecb909a85..9029ee1bcea 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -40,14 +40,13 @@ type response = {pid: pid_t, infd: fd_t, fn mk() -> handle { let setupport = port(); - let task = task::spawn_joinable( - chan(setupport), - fn (setupchan: chan>) { - let reqport = port(); - let reqchan = chan(reqport); - send(setupchan, reqchan); - worker(reqport); - }); + let setupchan = chan(setupport); + let task = task::spawn_joinable {|| + let reqport = port(); + let reqchan = chan(reqport); + send(setupchan, reqchan); + worker(reqport); + }; ret {task: option::some(task), chan: recv(setupport)}; } diff --git a/src/test/run-pass/basic-1.rs b/src/test/run-pass/basic-1.rs index 1afb2cbd1ff..fb610279c77 100644 --- a/src/test/run-pass/basic-1.rs +++ b/src/test/run-pass/basic-1.rs @@ -11,8 +11,9 @@ fn a(c: chan) { send(c, 10); } fn main() { let p = port(); - task::spawn(chan(p), a); - task::spawn(chan(p), a); + let ch = chan(p); + task::spawn {|| a(ch); }; + task::spawn {|| a(ch); }; let n: int = 0; n = recv(p); n = recv(p); diff --git a/src/test/run-pass/basic-2.rs b/src/test/run-pass/basic-2.rs index 077109d616a..6a238b4c4bc 100644 --- a/src/test/run-pass/basic-2.rs +++ b/src/test/run-pass/basic-2.rs @@ -2,6 +2,7 @@ use std; import comm; +import comm::port; import comm::send; import comm::chan; import comm::recv; @@ -10,9 +11,10 @@ import task; fn a(c: chan) { #debug("task a0"); #debug("task a1"); send(c, 10); } fn main() { - let p = comm::port(); - task::spawn(chan(p), a); - task::spawn(chan(p), b); + let p = port(); + let ch = chan(p); + task::spawn {|| a(ch); }; + task::spawn {|| b(ch); }; let n: int = 0; n = recv(p); n = recv(p); diff --git a/src/test/run-pass/basic.rs b/src/test/run-pass/basic.rs index efeb8b88b15..323451c98ab 100644 --- a/src/test/run-pass/basic.rs +++ b/src/test/run-pass/basic.rs @@ -31,8 +31,9 @@ fn main() { let n: int = 2 + 3 * 7; let s: str = "hello there"; let p = comm::port(); - task::spawn(chan(p), a); - task::spawn(chan(p), b); + let ch = comm::chan(p); + task::spawn {|| a(ch); }; + task::spawn {|| b(ch); }; let x: int = 10; x = g(n, s); log(debug, x); diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index 56469dbb172..e5345f8a79e 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -87,10 +87,10 @@ fn test_ptr() { } fn test_task() { - fn f(&&_i: ()) { } + fn f() { } let f1 = f, f2 = f; - let t1 = task::spawn((), f1); - let t2 = task::spawn((), f2); + let t1 = task::spawn {|| f1(); }; + let t2 = task::spawn {|| f2(); }; assert (t1 == t1); assert (t1 != t2); diff --git a/src/test/run-pass/chan-leak.rs b/src/test/run-pass/chan-leak.rs index 171947050d8..f7adb1a0961 100644 --- a/src/test/run-pass/chan-leak.rs +++ b/src/test/run-pass/chan-leak.rs @@ -23,7 +23,8 @@ fn request_task(c: chan) { fn new() -> ctx { let p = port(); - let t = task::spawn(chan(p), request_task); + let ch = chan(p); + let t = task::spawn {|| request_task(ch); }; let cx: ctx; cx = recv(p); ret cx; diff --git a/src/test/run-pass/child-outlives-parent.rs b/src/test/run-pass/child-outlives-parent.rs index 04940947145..4eabfa478a7 100644 --- a/src/test/run-pass/child-outlives-parent.rs +++ b/src/test/run-pass/child-outlives-parent.rs @@ -5,4 +5,4 @@ import task; fn child2(&&s: str) { } -fn main() { let x = task::spawn("hi", child2); } +fn main() { let x = task::spawn {|| child2("hi"); }; } diff --git a/src/test/run-pass/comm.rs b/src/test/run-pass/comm.rs index 14b21a242bd..d3b648e4475 100644 --- a/src/test/run-pass/comm.rs +++ b/src/test/run-pass/comm.rs @@ -9,7 +9,8 @@ import task; fn main() { let p = comm::port(); - let t = task::spawn(chan(p), child); + let ch = comm::chan(p); + let t = task::spawn {|| child(ch); }; let y = recv(p); #error("received"); log(error, y); diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 8670a53ac33..5c6e14e93a8 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -33,12 +33,12 @@ mod map_reduce { tag ctrl_proto { find_reducer([u8], chan); mapper_done; } fn start_mappers(ctrl: chan, inputs: [str]) { - for i: str in inputs { task::spawn((ctrl, i), map_task); } + for i: str in inputs { + task::spawn {|| map_task(ctrl, i); }; + } } - fn map_task(&&args: (chan, str)) { - let (ctrl, input) = args; - + fn map_task(ctrl: chan, input: str) { let intermediates = map::new_str_hash(); fn emit(im: map::hashmap, ctrl: chan, key: str, diff --git a/src/test/run-pass/issue-507.rs b/src/test/run-pass/issue-507.rs index 716b9dd16db..3cb790063a9 100644 --- a/src/test/run-pass/issue-507.rs +++ b/src/test/run-pass/issue-507.rs @@ -18,14 +18,15 @@ import comm::recv; fn grandchild(c: chan) { send(c, 42); } fn child(c: chan) { - let _grandchild = task::spawn_joinable(copy c, grandchild); + let _grandchild = task::spawn_joinable {|| grandchild(c); }; join(_grandchild); } fn main() { let p = comm::port(); + let ch = chan(p); - let _child = task::spawn_joinable(chan(p), child); + let _child = task::spawn_joinable {|| child(ch); }; let x: int = recv(p); diff --git a/src/test/run-pass/issue-687.rs b/src/test/run-pass/issue-687.rs index 2c0a2ae7afc..8ff6b4bab27 100644 --- a/src/test/run-pass/issue-687.rs +++ b/src/test/run-pass/issue-687.rs @@ -15,8 +15,7 @@ fn producer(c: chan<[u8]>) { send(c, empty); } -fn packager(&&args: (chan>, chan)) { - let (cb, msg) = args; +fn packager(cb: chan>, msg: chan) { let p: port<[u8]> = port(); send(cb, chan(p)); while true { @@ -39,11 +38,13 @@ fn packager(&&args: (chan>, chan)) { fn main() { let p: port = port(); + let ch = chan(p); let recv_reader: port> = port(); - let pack = task::spawn((chan(recv_reader), chan(p)), packager); + let recv_reader_chan = chan(recv_reader); + let pack = task::spawn {|| packager(recv_reader_chan, ch); }; let source_chan: chan<[u8]> = recv(recv_reader); - let prod = task::spawn(source_chan, producer); + let prod = task::spawn {|| producer(source_chan); }; while true { let msg = recv(p); diff --git a/src/test/run-pass/issue-783.rs b/src/test/run-pass/issue-783.rs index 086e6529320..27384b102eb 100644 --- a/src/test/run-pass/issue-783.rs +++ b/src/test/run-pass/issue-783.rs @@ -2,14 +2,15 @@ use std; import comm::*; import task::*; -fn a(&&_args: ()) { +fn a() { fn doit() { fn b(c: chan>) { let p = port(); send(c, chan(p)); } let p = port(); - spawn(chan(p), b); + let ch = chan(p); + spawn {|| b(ch); }; recv(p); } let i = 0; @@ -20,6 +21,6 @@ fn a(&&_args: ()) { } fn main() { - let t = spawn_joinable((), a); + let t = spawn_joinable {|| a(); }; join(t); } diff --git a/src/test/run-pass/ivec-tag.rs b/src/test/run-pass/ivec-tag.rs index 41b06d9294c..dce947bb622 100644 --- a/src/test/run-pass/ivec-tag.rs +++ b/src/test/run-pass/ivec-tag.rs @@ -15,7 +15,8 @@ fn producer(c: chan<[u8]>) { fn main() { let p: port<[u8]> = port(); - let prod = task::spawn(chan(p), producer); + let ch = chan(p); + let prod = task::spawn {|| producer(ch); }; let data: [u8] = recv(p); } diff --git a/src/test/run-pass/join.rs b/src/test/run-pass/join.rs index 7652eb3e1d7..ef4073406b4 100644 --- a/src/test/run-pass/join.rs +++ b/src/test/run-pass/join.rs @@ -5,11 +5,11 @@ use std; import task::*; fn main() { - let other = spawn_joinable((), child); + let other = spawn_joinable {|| child(); }; #error("1"); yield(); join(other); #error("3"); } -fn child(&&_i: ()) { #error("2"); } +fn child() { #error("2"); } diff --git a/src/test/run-pass/lazychan.rs b/src/test/run-pass/lazychan.rs index 67ec699e070..2e604209618 100644 --- a/src/test/run-pass/lazychan.rs +++ b/src/test/run-pass/lazychan.rs @@ -6,15 +6,16 @@ import comm::*; fn main() { let p = port(); + let ch = chan(p); let y: int; - task::spawn(chan(p), child); + task::spawn {|| child(ch); }; y = recv(p); #debug("received 1"); log(debug, y); assert (y == 10); - task::spawn(chan(p), child); + task::spawn {|| child(ch); }; y = recv(p); #debug("received 2"); log(debug, y); diff --git a/src/test/run-pass/linked-failure.rs b/src/test/run-pass/linked-failure.rs index 7e9b1571efe..b82aa7c2cb0 100644 --- a/src/test/run-pass/linked-failure.rs +++ b/src/test/run-pass/linked-failure.rs @@ -5,17 +5,17 @@ import task; import comm::port; import comm::recv; -fn child(&&_i: ()) { assert (1 == 2); } +fn child() { assert (1 == 2); } -fn parent(&&_i: ()) { +fn parent() { // Since this task isn't supervised it won't bring down the whole // process task::unsupervise(); let p = port::(); - task::spawn((), child); + task::spawn {|| child(); }; let x = recv(p); } fn main() { - task::spawn((), parent); + task::spawn {|| parent(); }; } \ No newline at end of file diff --git a/src/test/run-pass/lots-a-fail.rs b/src/test/run-pass/lots-a-fail.rs index f2f83a9b3d9..9f51b688b11 100644 --- a/src/test/run-pass/lots-a-fail.rs +++ b/src/test/run-pass/lots-a-fail.rs @@ -4,17 +4,17 @@ import task; import comm; import uint; -fn die(&&_i: ()) { +fn die() { fail; } -fn iloop(&&_i: ()) { +fn iloop() { task::unsupervise(); - task::spawn((), die); + task::spawn {|| die(); }; } fn main() { uint::range(0u, 100u) {|_i| - task::spawn((), iloop); + task::spawn {|| iloop(); }; } } \ No newline at end of file diff --git a/src/test/run-pass/many.rs b/src/test/run-pass/many.rs index 044e77d5f1e..0914e059b95 100644 --- a/src/test/run-pass/many.rs +++ b/src/test/run-pass/many.rs @@ -4,13 +4,13 @@ use std; import task; import comm; -fn sub(&&args: (comm::chan, int)) { - let (parent, id) = args; +fn sub(parent: comm::chan, id: int) { if id == 0 { comm::send(parent, 0); } else { let p = comm::port(); - let child = task::spawn((comm::chan(p), id - 1), sub); + let ch = comm::chan(p); + let child = task::spawn {|| sub(ch, id - 1); }; let y = comm::recv(p); comm::send(parent, y + 1); } @@ -18,7 +18,8 @@ fn sub(&&args: (comm::chan, int)) { fn main() { let p = comm::port(); - let child = task::spawn((comm::chan(p), 200), sub); + let ch = comm::chan(p); + let child = task::spawn {|| sub(ch, 200); }; let y = comm::recv(p); #debug("transmission complete"); log(debug, y); diff --git a/src/test/run-pass/morestack5.rs b/src/test/run-pass/morestack5.rs index aab001c5629..6c1d906e1e6 100644 --- a/src/test/run-pass/morestack5.rs +++ b/src/test/run-pass/morestack5.rs @@ -17,7 +17,7 @@ fn main() { let sz = 400u; while sz < 500u { rustrt::set_min_stack(sz); - task::join(task::spawn_joinable(200, getbig)); + task::join(task::spawn_joinable {|| getbig(200) }); sz += 1u; } } \ No newline at end of file diff --git a/src/test/run-pass/morestack6.rs b/src/test/run-pass/morestack6.rs index c72d4f98228..05c3e383126 100644 --- a/src/test/run-pass/morestack6.rs +++ b/src/test/run-pass/morestack6.rs @@ -32,12 +32,11 @@ fn calllink08() { rustrt::get_task_id(); } fn calllink09() { rustrt::sched_threads(); } fn calllink10() { rustrt::rust_get_task(); } -fn runtest(&&args:(fn(), u32)) { - let (f, frame_backoff) = args; +fn runtest(f: sendfn(), frame_backoff: u32) { runtest2(f, frame_backoff, 0 as *u8); } -fn runtest2(f: fn(), frame_backoff: u32, last_stk: *u8) -> u32 { +fn runtest2(f: sendfn(), frame_backoff: u32, last_stk: *u8) -> u32 { let curr_stk = rustrt::debug_get_stk_seg(); if (last_stk != curr_stk && last_stk != 0 as *u8) { // We switched stacks, go back and try to hit the dynamic linker @@ -73,6 +72,6 @@ fn main() { let sz = rng.next() % 256u32 + 256u32; let frame_backoff = rng.next() % 10u32 + 1u32; rustrt::set_min_stack(sz as uint); - task::join(task::spawn_joinable((f, frame_backoff), runtest)); + task::join(task::spawn_joinable {|| runtest(f, frame_backoff);}); } } \ No newline at end of file diff --git a/src/test/run-pass/send-iloop.rs b/src/test/run-pass/send-iloop.rs index b119ac6eb1d..5fb4e4e9bd9 100644 --- a/src/test/run-pass/send-iloop.rs +++ b/src/test/run-pass/send-iloop.rs @@ -4,13 +4,13 @@ import task; import comm; import uint; -fn die(&&_i: ()) { +fn die() { fail; } -fn iloop(&&_i: ()) { +fn iloop() { task::unsupervise(); - task::spawn((), die); + task::spawn {|| die(); }; let p = comm::port::<()>(); let c = comm::chan(p); while true { @@ -23,6 +23,6 @@ fn iloop(&&_i: ()) { fn main() { uint::range(0u, 16u) {|_i| - task::spawn((), iloop); + task::spawn {|| iloop(); }; } } \ No newline at end of file diff --git a/src/test/run-pass/sendfn-generic-fn.rs b/src/test/run-pass/sendfn-generic-fn.rs index 66177fd04ae..0a53d529d38 100644 --- a/src/test/run-pass/sendfn-generic-fn.rs +++ b/src/test/run-pass/sendfn-generic-fn.rs @@ -28,7 +28,7 @@ fn spawn(f: fn(sendfn(A,B)->pair)) { let arg = sendfn(a: A, b: B) -> pair { ret make_generic_record(a, b); }; - task::spawn(arg, f); + task::spawn {|| f(arg); }; } fn test05() { diff --git a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs index 84bc0759502..281a438b7ba 100644 --- a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs +++ b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs @@ -16,5 +16,7 @@ fn test05() { log(error, *three + n); // will copy x into the closure assert(*three == 3); }; - task::spawn(fn_to_send, test05_start); + task::spawn(sendfn[move fn_to_send]() { + test05_start(fn_to_send); + }); } diff --git a/src/test/run-pass/spawn-fn.rs b/src/test/run-pass/spawn-fn.rs index 68e0f22f2f8..92c6613c0fd 100644 --- a/src/test/run-pass/spawn-fn.rs +++ b/src/test/run-pass/spawn-fn.rs @@ -4,15 +4,15 @@ use std; import task::yield; import task; -fn x(&&args: (str, int)) { - let (s, n) = args; - log(debug, s); log(debug, n); +fn x(s: str, n: int) { + log(debug, s); + log(debug, n); } fn main() { - task::spawn(("hello from first spawned fn", 65), x); - task::spawn(("hello from second spawned fn", 66), x); - task::spawn(("hello from third spawned fn", 67), x); + task::spawn {|| x("hello from first spawned fn", 65); }; + task::spawn {|| x("hello from second spawned fn", 66); }; + task::spawn {|| x("hello from third spawned fn", 67); }; let i: int = 30; while i > 0 { i = i - 1; #debug("parent sleeping"); yield(); } } diff --git a/src/test/run-pass/spawn-module-qualified.rs b/src/test/run-pass/spawn-module-qualified.rs index 413474efd92..cbc3b8b2ea6 100644 --- a/src/test/run-pass/spawn-module-qualified.rs +++ b/src/test/run-pass/spawn-module-qualified.rs @@ -2,7 +2,7 @@ use std; import task::join; import task::spawn_joinable; -fn main() { let x = spawn_joinable(10, m::child); join(x); } +fn main() { let x = spawn_joinable {|| m::child(10); }; join(x); } mod m { fn child(&&i: int) { log(debug, i); } diff --git a/src/test/run-pass/spawn-types.rs b/src/test/run-pass/spawn-types.rs index fe6ea6374b1..727d8326b4e 100644 --- a/src/test/run-pass/spawn-types.rs +++ b/src/test/run-pass/spawn-types.rs @@ -12,12 +12,12 @@ import task; type ctx = comm::chan; -fn iotask(&&args: (ctx, str)) { - let (cx, ip) = args; +fn iotask(cx: ctx, ip: str) { assert (str::eq(ip, "localhost")); } fn main() { let p = comm::port::(); - task::spawn((comm::chan(p), "localhost"), iotask); + let ch = comm::chan(p); + task::spawn {|| iotask(ch, "localhost"); }; } diff --git a/src/test/run-pass/spawn.rs b/src/test/run-pass/spawn.rs index 52ceb4c27ab..7a395f677aa 100644 --- a/src/test/run-pass/spawn.rs +++ b/src/test/run-pass/spawn.rs @@ -4,7 +4,10 @@ use std; import task; -fn main() { let t = task::spawn_joinable(10, child); task::join(t); } +fn main() { + let t = task::spawn_joinable {|| child(10); }; + task::join(t); +} fn child(&&i: int) { log(error, i); assert (i == 10); } diff --git a/src/test/run-pass/spawn2.rs b/src/test/run-pass/spawn2.rs index 6d22149824f..86e2c996517 100644 --- a/src/test/run-pass/spawn2.rs +++ b/src/test/run-pass/spawn2.rs @@ -3,7 +3,7 @@ use std; import task::spawn; -fn main() { spawn((10, 20, 30, 40, 50, 60, 70, 80, 90), child); } +fn main() { spawn {|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)); }; } fn child(&&args: (int, int, int, int, int, int, int, int, int)) { let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args; diff --git a/src/test/run-pass/task-comm-0.rs b/src/test/run-pass/task-comm-0.rs index d54b31b07b5..0d0a70ae816 100644 --- a/src/test/run-pass/task-comm-0.rs +++ b/src/test/run-pass/task-comm-0.rs @@ -20,7 +20,7 @@ fn test05_start(ch : chan) { fn test05() { let po = comm::port(); let ch = comm::chan(po); - task::spawn(ch, test05_start); + task::spawn {|| test05_start(ch); }; let value = comm::recv(po); log(error, value); value = comm::recv(po); diff --git a/src/test/run-pass/task-comm-1.rs b/src/test/run-pass/task-comm-1.rs index 478eb3292ea..96901b9ae56 100644 --- a/src/test/run-pass/task-comm-1.rs +++ b/src/test/run-pass/task-comm-1.rs @@ -5,10 +5,10 @@ import task::join; fn main() { test00(); } -fn start(&&_i: ()) { #debug("Started / Finished task."); } +fn start() { #debug("Started / Finished task."); } fn test00() { - let t = spawn_joinable((), start); + let t = spawn_joinable {|| start(); }; join(t); #debug("Completing."); } diff --git a/src/test/run-pass/task-comm-10.rs b/src/test/run-pass/task-comm-10.rs index 84e4825ec9b..d3c1d19f3eb 100644 --- a/src/test/run-pass/task-comm-10.rs +++ b/src/test/run-pass/task-comm-10.rs @@ -18,7 +18,8 @@ fn start(c: comm::chan>) { fn main() { let p = comm::port(); - let child = task::spawn(comm::chan(p), start); + let ch = comm::chan(p); + let child = task::spawn {|| start(ch); }; let c = comm::recv(p); comm::send(c, "A"); diff --git a/src/test/run-pass/task-comm-11.rs b/src/test/run-pass/task-comm-11.rs index d8f3d12d059..b1e23b2443a 100644 --- a/src/test/run-pass/task-comm-11.rs +++ b/src/test/run-pass/task-comm-11.rs @@ -9,6 +9,7 @@ fn start(c: comm::chan>) { fn main() { let p = comm::port(); - let child = task::spawn(comm::chan(p), start); + let ch = comm::chan(p); + let child = task::spawn {|| start(ch); }; let c = comm::recv(p); } diff --git a/src/test/run-pass/task-comm-12.rs b/src/test/run-pass/task-comm-12.rs index 2f6adfea5dc..f92585cd254 100644 --- a/src/test/run-pass/task-comm-12.rs +++ b/src/test/run-pass/task-comm-12.rs @@ -7,7 +7,7 @@ fn start(&&task_number: int) { #debug("Started / Finished task."); } fn test00() { let i: int = 0; - let t = task::spawn_joinable(i, start); + let t = task::spawn_joinable {|| start(i); }; // Sleep long enough for the task to finish. task::sleep(10000u); diff --git a/src/test/run-pass/task-comm-13.rs b/src/test/run-pass/task-comm-13.rs index c2a15229f88..dc2393d13f4 100644 --- a/src/test/run-pass/task-comm-13.rs +++ b/src/test/run-pass/task-comm-13.rs @@ -3,8 +3,7 @@ import task; import comm; import comm::send; -fn start(&&args: (comm::chan, int, int)) { - let (c, start, number_of_messages) = args; +fn start(c: comm::chan, start: int, number_of_messages: int) { let i: int = 0; while i < number_of_messages { send(c, start + i); i += 1; } } @@ -12,7 +11,8 @@ fn start(&&args: (comm::chan, int, int)) { fn main() { #debug("Check that we don't deadlock."); let p = comm::port::(); - let a = task::spawn_joinable((comm::chan(p), 0, 10), start); + let ch = comm::chan(p); + let a = task::spawn_joinable {|| start(ch, 0, 10); }; task::join(a); #debug("Joined task"); } diff --git a/src/test/run-pass/task-comm-14.rs b/src/test/run-pass/task-comm-14.rs index e37eb15ce39..48f4ca7a8b2 100644 --- a/src/test/run-pass/task-comm-14.rs +++ b/src/test/run-pass/task-comm-14.rs @@ -4,12 +4,13 @@ import task; fn main() { let po = comm::port::(); + let ch = comm::chan(po); // Spawn 10 tasks each sending us back one int. let i = 10; while (i > 0) { log(debug, i); - task::spawn((i, comm::chan(po)), child); + task::spawn {|| child(i, ch); }; i = i - 1; } @@ -27,8 +28,7 @@ fn main() { #debug("main thread exiting"); } -fn child(&&args: (int, comm::chan)) { - let (x, ch) = args; +fn child(x: int, ch: comm::chan) { log(debug, x); - comm::send(ch, x); + comm::send(ch, copy x); } diff --git a/src/test/run-pass/task-comm-15.rs b/src/test/run-pass/task-comm-15.rs index c526f54203d..d762b7fca90 100644 --- a/src/test/run-pass/task-comm-15.rs +++ b/src/test/run-pass/task-comm-15.rs @@ -3,10 +3,12 @@ use std; import comm; import task; -fn start(&&args: (comm::chan, int)) { - let (c, i) = args; - - while i > 0 { comm::send(c, 0); i = i - 1; } +fn start(c: comm::chan, i0: int) { + let i = i0; + while i > 0 { + comm::send(c, 0); + i = i - 1; + } } fn main() { @@ -15,6 +17,7 @@ fn main() { // is likely to terminate before the child completes, so from // the child's point of view the receiver may die. We should // drop messages on the floor in this case, and not crash! - let child = task::spawn((comm::chan(p), 10), start); + let ch = comm::chan(p); + let child = task::spawn {|| start(ch, 10); }; let c = comm::recv(p); } diff --git a/src/test/run-pass/task-comm-2.rs b/src/test/run-pass/task-comm-2.rs index 6ad262bc3ab..c17b1c8a11e 100644 --- a/src/test/run-pass/task-comm-2.rs +++ b/src/test/run-pass/task-comm-2.rs @@ -22,7 +22,7 @@ fn test00() { let tasks = []; while i < number_of_tasks { i = i + 1; - tasks += [task::spawn_joinable(copy i, start)]; + tasks += [task::spawn_joinable {|| start(i); }]; } for t in tasks { task::join(t); } diff --git a/src/test/run-pass/task-comm-3.rs b/src/test/run-pass/task-comm-3.rs index 407939c9e65..d5826309356 100644 --- a/src/test/run-pass/task-comm-3.rs +++ b/src/test/run-pass/task-comm-3.rs @@ -7,8 +7,7 @@ import comm::recv; fn main() { #debug("===== WITHOUT THREADS ====="); test00(); } -fn test00_start(&&args: (chan, int, int)) { - let (ch, message, count) = args; +fn test00_start(ch: chan, message: int, count: int) { #debug("Starting test00_start"); let i: int = 0; while i < count { @@ -33,8 +32,9 @@ fn test00() { // Create and spawn tasks... let tasks = []; while i < number_of_tasks { - tasks += [task::spawn_joinable( - (ch, i, number_of_messages), test00_start)]; + tasks += [task::spawn_joinable {|| + test00_start(ch, i, number_of_messages) + }]; i = i + 1; } diff --git a/src/test/run-pass/task-comm-7.rs b/src/test/run-pass/task-comm-7.rs index 07b82a17987..c7c15830955 100644 --- a/src/test/run-pass/task-comm-7.rs +++ b/src/test/run-pass/task-comm-7.rs @@ -7,8 +7,7 @@ import comm::port; fn main() { test00(); } -fn test00_start(&&args: (comm::chan, int, int)) { - let (c, start, number_of_messages) = args; +fn test00_start(c: comm::chan, start: int, number_of_messages: int) { let i: int = 0; while i < number_of_messages { comm::send(c, start + i); i += 1; } } @@ -18,23 +17,20 @@ fn test00() { let sum: int = 0; let p = port(); let number_of_messages: int = 10; + let c = chan(p); - let t0 = - task::spawn_joinable((chan(p), - number_of_messages * 0, - number_of_messages), test00_start); - let t1 = - task::spawn_joinable((chan(p), - number_of_messages * 1, - number_of_messages), test00_start); - let t2 = - task::spawn_joinable((chan(p), - number_of_messages * 2, - number_of_messages), test00_start); - let t3 = - task::spawn_joinable((chan(p), - number_of_messages * 3, - number_of_messages), test00_start); + let t0 = task::spawn_joinable {|| + test00_start(c, number_of_messages * 0, number_of_messages); + }; + let t1 = task::spawn_joinable {|| + test00_start(c, number_of_messages * 1, number_of_messages); + }; + let t2 = task::spawn_joinable {|| + test00_start(c, number_of_messages * 2, number_of_messages); + }; + let t3 = task::spawn_joinable {|| + test00_start(c, number_of_messages * 3, number_of_messages); + }; let i: int = 0; while i < number_of_messages { diff --git a/src/test/run-pass/task-comm-8.rs b/src/test/run-pass/task-comm-8.rs index bd2cc06cd4b..8259fde9fad 100644 --- a/src/test/run-pass/task-comm-8.rs +++ b/src/test/run-pass/task-comm-8.rs @@ -4,8 +4,7 @@ import comm; fn main() { test00(); } -fn test00_start(&&args: (comm::chan, int, int)) { - let (c, start, number_of_messages) = args; +fn test00_start(c: comm::chan, start: int, number_of_messages: int) { let i: int = 0; while i < number_of_messages { comm::send(c, start + i); i += 1; } } @@ -14,24 +13,21 @@ fn test00() { let r: int = 0; let sum: int = 0; let p = comm::port(); + let c = comm::chan(p); let number_of_messages: int = 10; - let t0 = - task::spawn_joinable((comm::chan(p), - number_of_messages * 0, - number_of_messages), test00_start); - let t1 = - task::spawn_joinable((comm::chan(p), - number_of_messages * 1, - number_of_messages), test00_start); - let t2 = - task::spawn_joinable((comm::chan(p), - number_of_messages * 2, - number_of_messages), test00_start); - let t3 = - task::spawn_joinable((comm::chan(p), - number_of_messages * 3, - number_of_messages), test00_start); + let t0 = task::spawn_joinable {|| + test00_start(c, number_of_messages * 0, number_of_messages); + }; + let t1 = task::spawn_joinable {|| + test00_start(c, number_of_messages * 1, number_of_messages); + }; + let t2 = task::spawn_joinable {|| + test00_start(c, number_of_messages * 2, number_of_messages); + }; + let t3 = task::spawn_joinable {|| + test00_start(c, number_of_messages * 3, number_of_messages); + }; let i: int = 0; while i < number_of_messages { diff --git a/src/test/run-pass/task-comm-9.rs b/src/test/run-pass/task-comm-9.rs index 703fb3fc2a0..f6cc1dae6f0 100644 --- a/src/test/run-pass/task-comm-9.rs +++ b/src/test/run-pass/task-comm-9.rs @@ -4,8 +4,7 @@ import comm; fn main() { test00(); } -fn test00_start(&&args: (comm::chan, int)) { - let (c, number_of_messages) = args; +fn test00_start(c: comm::chan, number_of_messages: int) { let i: int = 0; while i < number_of_messages { comm::send(c, i + 0); i += 1; } } @@ -15,9 +14,11 @@ fn test00() { let sum: int = 0; let p = comm::port(); let number_of_messages: int = 10; + let ch = comm::chan(p); - let t0 = task::spawn_joinable((comm::chan(p), number_of_messages), - test00_start); + let t0 = task::spawn_joinable {|| + test00_start(ch, number_of_messages); + }; let i: int = 0; while i < number_of_messages { diff --git a/src/test/run-pass/task-comm-chan-cleanup4.rs b/src/test/run-pass/task-comm-chan-cleanup4.rs index d7553afb8bb..4593c90293a 100644 --- a/src/test/run-pass/task-comm-chan-cleanup4.rs +++ b/src/test/run-pass/task-comm-chan-cleanup4.rs @@ -12,16 +12,17 @@ fn starship(&&ch: comm::chan) { } } -fn starbase(&&_args: ()) { +fn starbase() { int::range(0, 10) { |_i| let p = comm::port(); - task::spawn(comm::chan(p), starship); + let c = comm::chan(p); + task::spawn {|| starship(c);}; task::yield(); } } fn main() { int::range(0, 10) { |_i| - task::spawn((), starbase); + task::spawn {|| starbase();}; } } \ No newline at end of file diff --git a/src/test/run-pass/task-comm.rs b/src/test/run-pass/task-comm.rs index 85a9fb8dfbd..bd9d359383c 100644 --- a/src/test/run-pass/task-comm.rs +++ b/src/test/run-pass/task-comm.rs @@ -18,8 +18,7 @@ fn main() { test06(); } -fn test00_start(&&args: (chan, int, int)) { - let (ch, message, count) = args; +fn test00_start(ch: chan, message: int, count: int) { #debug("Starting test00_start"); let i: int = 0; while i < count { @@ -43,8 +42,9 @@ fn test00() { let tasks = []; while i < number_of_tasks { i = i + 1; - tasks += [task::spawn_joinable( - (ch, i, number_of_messages), test00_start)]; + tasks += [ + task::spawn_joinable {|| test00_start(ch, i, number_of_messages);} + ]; } let sum: int = 0; for t in tasks { @@ -90,7 +90,7 @@ fn test03() { log(debug, v.length()); } -fn test04_start(&&_args: ()) { +fn test04_start() { #debug("Started task"); let i: int = 1024 * 1024; while i > 0 { i = i - 1; } @@ -100,7 +100,7 @@ fn test04_start(&&_args: ()) { fn test04() { #debug("Spawning lots of tasks."); let i: int = 4; - while i > 0 { i = i - 1; task::spawn((), test04_start); } + while i > 0 { i = i - 1; task::spawn {|| test04_start(); }; } #debug("Finishing up."); } @@ -115,7 +115,7 @@ fn test05_start(ch: chan) { fn test05() { let po = comm::port(); let ch = chan(po); - task::spawn(ch, test05_start); + task::spawn {|| test05_start(ch); }; let value: int; value = recv(po); value = recv(po); @@ -139,7 +139,7 @@ fn test06() { let tasks = []; while i < number_of_tasks { i = i + 1; - tasks += [task::spawn_joinable(copy i, test06_start)]; + tasks += [task::spawn_joinable {|| test06_start(i);}]; } diff --git a/src/test/run-pass/task-killjoin.rs b/src/test/run-pass/task-killjoin.rs index a4ba23ef925..313d9bd3702 100644 --- a/src/test/run-pass/task-killjoin.rs +++ b/src/test/run-pass/task-killjoin.rs @@ -9,7 +9,7 @@ use std; import task; -fn supervised(&&_args: ()) { +fn supervised() { // Yield to make sure the supervisor joins before we // fail. This is currently not needed because the supervisor // runs first, but I can imagine that changing. @@ -17,17 +17,17 @@ fn supervised(&&_args: ()) { fail; } -fn supervisor(&&_args: ()) { +fn supervisor() { // Unsupervise this task so the process doesn't return a failure status as // a result of the main task being killed. task::unsupervise(); let f = supervised; - let t = task::spawn_joinable((), supervised); + let t = task::spawn_joinable {|| supervised(); }; task::join(t); } fn main() { - let dom2 = task::spawn_joinable((), supervisor); + let dom2 = task::spawn_joinable {|| supervisor(); }; task::join(dom2); } diff --git a/src/test/run-pass/task-life-0.rs b/src/test/run-pass/task-life-0.rs index 47afb2aec5f..1aead283758 100644 --- a/src/test/run-pass/task-life-0.rs +++ b/src/test/run-pass/task-life-0.rs @@ -1,6 +1,8 @@ use std; import task; -fn main() { task::spawn("Hello", child); } +fn main() { + task::spawn {|| child("Hello"); }; +} fn child(&&s: str) { diff --git a/src/test/run-pass/terminate-in-initializer.rs b/src/test/run-pass/terminate-in-initializer.rs index f3fdeea259b..23597b3ed62 100644 --- a/src/test/run-pass/terminate-in-initializer.rs +++ b/src/test/run-pass/terminate-in-initializer.rs @@ -11,14 +11,14 @@ fn test_cont() { let i = 0; while i < 1 { i += 1; let x: @int = cont; } } fn test_ret() { let x: @int = ret; } fn test_fail() { - fn f(&&_i: ()) { task::unsupervise(); let x: @int = fail; } - task::spawn((), f); + fn f() { task::unsupervise(); let x: @int = fail; } + task::spawn {|| f(); }; } fn test_fail_indirect() { fn f() -> ! { fail; } - fn g(&&_i: ()) { task::unsupervise(); let x: @int = f(); } - task::spawn((), g); + fn g() { task::unsupervise(); let x: @int = f(); } + task::spawn {|| g(); }; } fn main() { diff --git a/src/test/run-pass/threads.rs b/src/test/run-pass/threads.rs index 2f09d1c6b4f..9f4e6e1fdd8 100644 --- a/src/test/run-pass/threads.rs +++ b/src/test/run-pass/threads.rs @@ -5,7 +5,7 @@ import task; fn main() { let i = 10; - while i > 0 { task::spawn(copy i, child); i = i - 1; } + while i > 0 { task::spawn {|| child(i); }; i = i - 1; } #debug("main thread exiting"); } diff --git a/src/test/run-pass/unique-send-2.rs b/src/test/run-pass/unique-send-2.rs index 1625e7cc9c1..976ca32104e 100644 --- a/src/test/run-pass/unique-send-2.rs +++ b/src/test/run-pass/unique-send-2.rs @@ -3,17 +3,17 @@ import comm; import task; import uint; -fn child(args: (comm::chan<~uint>, uint)) { - let (c, i) = args; +fn child(c: comm::chan<~uint>, i: uint) { comm::send(c, ~i); } fn main() { let p = comm::port(); + let ch = comm::chan(p); let n = 100u; let expected = 0u; uint::range(0u, n) {|i| - task::spawn((comm::chan(p), i), child); + task::spawn {|| child(ch, i); }; expected += i; } diff --git a/src/test/run-pass/unwind-box.rs b/src/test/run-pass/unwind-box.rs index 9cfcd5f5c55..ca4221e0763 100644 --- a/src/test/run-pass/unwind-box.rs +++ b/src/test/run-pass/unwind-box.rs @@ -2,12 +2,12 @@ use std; import task; -fn f(&&_i: ()) { +fn f() { task::unsupervise(); let a = @0; fail; } fn main() { - task::spawn((), f); + task::spawn {|| f(); }; } \ No newline at end of file diff --git a/src/test/run-pass/unwind-resource.rs b/src/test/run-pass/unwind-resource.rs index eaaee443cfc..5bb70236b7c 100644 --- a/src/test/run-pass/unwind-resource.rs +++ b/src/test/run-pass/unwind-resource.rs @@ -16,6 +16,6 @@ fn f(c: comm::chan) { fn main() { let p = comm::port(); let c = comm::chan(p); - task::spawn(c, f); + task::spawn {|| f(c); }; assert comm::recv(p); } \ No newline at end of file diff --git a/src/test/run-pass/unwind-resource2.rs b/src/test/run-pass/unwind-resource2.rs index 3d55982a5bb..dbf91f31a3f 100644 --- a/src/test/run-pass/unwind-resource2.rs +++ b/src/test/run-pass/unwind-resource2.rs @@ -6,12 +6,12 @@ import comm; resource complainer(c: @int) { } -fn f(&&_i: ()) { +fn f() { task::unsupervise(); let c <- complainer(@0); fail; } fn main() { - task::spawn((), f); + task::spawn {|| f(); }; } \ No newline at end of file diff --git a/src/test/run-pass/unwind-unique.rs b/src/test/run-pass/unwind-unique.rs index 40005d733f5..9fab3c54609 100644 --- a/src/test/run-pass/unwind-unique.rs +++ b/src/test/run-pass/unwind-unique.rs @@ -2,12 +2,12 @@ use std; import task; -fn f(&&_i: ()) { +fn f() { task::unsupervise(); let a = ~0; fail; } fn main() { - task::spawn((), f); + task::spawn {|| f(); }; } \ No newline at end of file diff --git a/src/test/run-pass/yield.rs b/src/test/run-pass/yield.rs index 43cfecf2045..eb4a74c141a 100644 --- a/src/test/run-pass/yield.rs +++ b/src/test/run-pass/yield.rs @@ -4,7 +4,7 @@ import task; import task::*; fn main() { - let other = task::spawn_joinable((), child); + let other = task::spawn_joinable {|| child(); }; #error("1"); yield(); #error("2"); @@ -13,6 +13,6 @@ fn main() { join(other); } -fn child(&&_i: ()) { +fn child() { #error("4"); yield(); #error("5"); yield(); #error("6"); } diff --git a/src/test/run-pass/yield1.rs b/src/test/run-pass/yield1.rs index 3b4795a47a1..a5234cf8d12 100644 --- a/src/test/run-pass/yield1.rs +++ b/src/test/run-pass/yield1.rs @@ -4,10 +4,10 @@ import task; import task::*; fn main() { - let other = task::spawn_joinable((), child); + let other = task::spawn_joinable {|| child(); }; #error("1"); yield(); join(other); } -fn child(&&_i: ()) { #error("2"); } +fn child() { #error("2"); } diff --git a/src/test/stdtest/task.rs b/src/test/stdtest/task.rs index 500189a0bc6..7945aaed744 100644 --- a/src/test/stdtest/task.rs +++ b/src/test/stdtest/task.rs @@ -12,13 +12,13 @@ fn test_sleep() { task::sleep(1000000u); } #[ignore(cfg(target_os = "win32"))] fn test_unsupervise() { fn f() { task::unsupervise(); fail; } - task::spawn {|| f}; + task::spawn {|| f();}; } #[test] fn test_lib_spawn() { fn foo() { #error("Hello, World!"); } - task::spawn {|| foo}; + task::spawn {|| foo();}; } #[test] @@ -54,6 +54,6 @@ fn test_join_chan_fail() { #[test] fn spawn_polymorphic() { fn foo(x: T) { log(error, x); } - task::spawn {|| foo(true);} - task::spawn {|| foo(42);} + task::spawn {|| foo(true);}; + task::spawn {|| foo(42);}; } diff --git a/src/test/stdtest/vec.rs b/src/test/stdtest/vec.rs index 9994463ec3c..3bbea1db6be 100644 --- a/src/test/stdtest/vec.rs +++ b/src/test/stdtest/vec.rs @@ -509,10 +509,10 @@ fn init() { fn init_empty() { let r = task::join( - task::spawn_joinable((), fn (&&_i: ()) { + task::spawn_joinable {|| task::unsupervise(); vec::init::([]); - })); + }); assert r == task::tr_failure }