Add tests from vibe-d:core.
This commit is contained in:
parent
99bc332a81
commit
5a8d5a2fea
7 changed files with 354 additions and 0 deletions
42
tests/vibe.core.net.1376.d
Normal file
42
tests/vibe.core.net.1376.d
Normal file
|
@ -0,0 +1,42 @@
|
|||
/+ dub.sdl:
|
||||
name "tests"
|
||||
description "TCP disconnect task issue"
|
||||
dependency "vibe-core" path="../"
|
||||
versions "VibeDefaultMain"
|
||||
+/
|
||||
module test;
|
||||
|
||||
import vibe.core.core;
|
||||
import vibe.core.net;
|
||||
import core.time : msecs;
|
||||
|
||||
shared static this()
|
||||
{
|
||||
listenTCP(11375,(conn){
|
||||
auto td = runTask!TCPConnection((conn) {
|
||||
ubyte [3] buf;
|
||||
try {
|
||||
conn.read(buf);
|
||||
assert(false, "Expected read() to throw an exception.");
|
||||
} catch (Exception) {} // expected
|
||||
}, conn);
|
||||
sleep(10.msecs);
|
||||
conn.close();
|
||||
});
|
||||
|
||||
runTask({
|
||||
try {
|
||||
auto conn = connectTCP("127.0.0.1", 11375);
|
||||
conn.write("a");
|
||||
conn.close();
|
||||
} catch (Exception e) assert(false, e.msg);
|
||||
|
||||
try {
|
||||
auto conn = connectTCP("127.0.0.1", 11375);
|
||||
conn.close();
|
||||
} catch (Exception e) assert(false, e.msg);
|
||||
|
||||
sleep(50.msecs);
|
||||
exitEventLoop();
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue