From 19ea38fc729adf355bf6710005fd75143a9ab2dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sun, 16 Jun 2019 22:30:34 +0200 Subject: [PATCH] Add test for #157. --- tests/issue-157-consume-closed-channel.d | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/issue-157-consume-closed-channel.d diff --git a/tests/issue-157-consume-closed-channel.d b/tests/issue-157-consume-closed-channel.d new file mode 100644 index 0000000..8c0dfb9 --- /dev/null +++ b/tests/issue-157-consume-closed-channel.d @@ -0,0 +1,29 @@ +/+ dub.sdl: + name "tests" + dependency "vibe-core" path=".." ++/ +module tests; + +import vibe.core.channel; +import vibe.core.core; +import core.time; + +void main() +{ + auto ch = createChannel!int(); + + auto p = runTask({ + sleep(1.seconds); + ch.close(); + }); + + auto c = runTask({ + while (!ch.empty) { + try ch.consumeOne(); + catch (Exception e) assert(false, e.msg); + } + }); + + p.join(); + c.join(); +}