Test leaking handles through the GC.

This commit is contained in:
Sönke Ludwig 2018-10-26 15:41:18 +02:00
parent 5deeced2b5
commit 38a4e4ca5f

36
tests/0-leaked-handles.d Normal file
View file

@ -0,0 +1,36 @@
/++ dub.sdl:
name "test"
dependency "eventcore" path=".."
+/
module test;
import eventcore.core;
import eventcore.driver;
import std.socket : InternetAddress;
class C {
DatagramSocketFD m_handle;
EventDriver m_driver;
this()
{
auto addr = new InternetAddress(0x7F000001, 40001);
m_handle = eventDriver.sockets.createDatagramSocket(addr, null);
assert(m_handle != DatagramSocketFD.invalid);
m_driver = eventDriver;
}
~this()
{
assert(eventDriver is m_driver);
eventDriver.sockets.releaseRef(m_handle);
}
}
void main()
{
// let the GC clean up at app exit
// note that this happens *after* the static module destructors have been run
new C;
}