From 4465c1ad022740eb9204f3111396be6b16351632 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 15 Dec 2011 16:10:01 -0800 Subject: [PATCH] first test of sendable fns (passes) --- src/test/run-pass/sendfn-spawn-with-fn-arg.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/test/run-pass/sendfn-spawn-with-fn-arg.rs diff --git a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs new file mode 100644 index 00000000000..d96345e9e41 --- /dev/null +++ b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs @@ -0,0 +1,20 @@ +use std; + +import std::comm; +import std::comm::chan; +import std::comm::send; + +fn main() { test05(); } + +fn test05_start(&&f: sendfn(int)) { + f(22); +} + +fn test05() { + let three = ~3; + let fn_to_send = sendfn(n: int) { + log_err *three + n; // will copy x into the closure + assert(*three == 3); + }; + task::spawn(fn_to_send, test05_start); +}