diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/actor/accept/drop_closes.zc | 25 | ||||
| -rw-r--r-- | tests/drivers/actor_test.py | 2 |
2 files changed, 26 insertions, 1 deletions
diff --git a/tests/actor/accept/drop_closes.zc b/tests/actor/accept/drop_closes.zc new file mode 100644 index 0000000..08fd02c --- /dev/null +++ b/tests/actor/accept/drop_closes.zc @@ -0,0 +1,25 @@ +// destructors: an actor's drop waits for the replies its receiver is owed, then closes the endpoint, so the worker is gone when the owner's block ends; a struct that declares its own drop keeps it +namespace; +include rt, actor; +actor Echo { int total; int handle(int x) { return x; } } +int closed; +actor Mine { int total; int handle(int x) { return x; } void drop() { closed++; } } +fn main() { + int before = rt.syscall(55, 0, 0, 0); + { + Echo* e = rt.new(Echo); + e.spawn(); + rt.put_n(rt.syscall(55, 0, 0, 0) - before); rt.put_c(32); + } + rt.put_n(rt.syscall(55, 0, 0, 0) - before); rt.put_c(32); + let total = 0; + { + Echo* f = rt.new(Echo); + f.spawn(); f.recv(fn(int n) { total += n; return 0; }); f.send(5); f.send(6); + } + rt.put_n(total); rt.put_c(32); + rt.put_n(rt.syscall(55, 0, 0, 0) - before); rt.put_c(32); + { Mine* m = rt.new(Mine); } + rt.put_n(closed); rt.put_c(10); + return 0; +} diff --git a/tests/drivers/actor_test.py b/tests/drivers/actor_test.py index 929bbf4..e8988c0 100644 --- a/tests/drivers/actor_test.py +++ b/tests/drivers/actor_test.py @@ -11,7 +11,7 @@ parser.add_argument('--case', default='') parser.add_argument('--library', default='') args = parser.parse_args() root = Path(__file__).resolve().parents[2] -expected = {'parallel': '0 0\n11 21\n', 'state': '0 5 7\n4\n', 'graphs': '25 a 5\n', 'results': 'ok\n', 'plain': '3\n', 'module_helpers': '10\n', 'safepoint': '8\n', 'values': '1\n', 'functions': '12\n', 'pointer_scalar': '1\n', 'declaration': '5 7 0 0\n', 'lifecycle': '-1 3\n', 'generic_extensions': '3\n', 'failed_worker': '-1 -1 3\n', 'generic_declaration': '5 7 4 0\n', 'generic_typed_method': '7 2\n'} +expected = {'parallel': '0 0\n11 21\n', 'state': '0 5 7\n4\n', 'graphs': '25 a 5\n', 'results': 'ok\n', 'plain': '3\n', 'module_helpers': '10\n', 'safepoint': '8\n', 'values': '1\n', 'functions': '12\n', 'pointer_scalar': '1\n', 'declaration': '5 7 0 0\n', 'lifecycle': '-1 3\n', 'generic_extensions': '3\n', 'failed_worker': '-1 -1 3\n', 'generic_declaration': '5 7 4 0\n', 'generic_typed_method': '7 2\n', 'drop_closes': '1 0 11 0 1\n'} count = 0 for case in sorted((root / 'tests/actor').glob('*/*.zc')): if args.case and args.case not in str(case): |
