diff options
Diffstat (limited to 'tests/actor/accept/generic_declaration.zc')
| -rw-r--r-- | tests/actor/accept/generic_declaration.zc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/actor/accept/generic_declaration.zc b/tests/actor/accept/generic_declaration.zc new file mode 100644 index 0000000..a5e5e77 --- /dev/null +++ b/tests/actor/accept/generic_declaration.zc @@ -0,0 +1,15 @@ +namespace; +include rt, actor; +typecheck on; +actor Counter<T> { T total; T handle(T input) { this.total += input; return this.total; } } +fn main() { + Counter<int>* a = rt.new(Counter<int>), b = rt.new(Counter<int>); + Counter<float>* c = rt.new(Counter<float>); int left = 0, right = 0, floating = 0; + a.spawn(); b.spawn(); c.spawn(); + a.recv(fn(int n) { left = n; return 0; }); b.recv(fn(int n) { right = n; return 0; }); + c.recv(fn(float n) { floating = n; return 0; }); + a.send(2); a.send(3); b.send(7); c.send(1.5); c.send(2.5); + a.await(); b.await(); c.await(); + rt.put_n(left); rt.put_c(' '); rt.put_n(right); rt.put_c(' '); rt.put_n(floating); rt.put_c(' '); rt.put_n(a.total); rt.put_c(10); + a.close(); b.close(); c.close(); return 0; +} |
