diff options
Diffstat (limited to 'tests/actor/accept/functions.zc')
| -rw-r--r-- | tests/actor/accept/functions.zc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/actor/accept/functions.zc b/tests/actor/accept/functions.zc new file mode 100644 index 0000000..f869789 --- /dev/null +++ b/tests/actor/accept/functions.zc @@ -0,0 +1,12 @@ +namespace; +include rt, actor; +typecheck on; +type Operation = int(int); +int handle(Operation operation) { return operation(3); } +fn main() { + actor.Actor<Operation,int>* a = rt.new(actor.Actor<Operation,int>); + a.spawn(handle); let result = 0; a.recv(fn(int n) { result = n; return 0; }); + char* text = rt.new(char, 3); text[0] = 'a'; text[1] = 'b'; let offset = 7; float scale = 2.0; + Operation operation = fn:int(int n) { if (scale == 2.0) return n + offset + rt.len_w(text); return -1; }; + a.send(operation); a.await(); rt.put_n(result); rt.put_c(10); a.close(); return 0; +} |
