Don't compile unittests by default.
[software/ev.d.git] / dtest.d
1 /+
2  + D Programming Language "bindings" to libev
3  + <http://software.schmorp.de/pkg/libev.html> test program.
4  +
5  + Written by Leandro Lucarella (2008).
6  +
7  + Placed under BOLA license <http://auriga.wearlab.de/~alb/bola/> which is
8  + basically public domain.
9  +
10  +/
11
12 import std.stdio;
13 import ev.d;
14
15 void main()
16 {
17         auto iow = new Io(0, READ,
18                 (Io w, int revents)
19                 {
20                         writefln("stdin ready");
21                         char[] ln = readln();
22                         writef("read %d bytes: %s", ln.length, ln);
23                         w.stop; // just a syntax example
24                         assert (w.loop !is null);
25                         w.loop.unloop(Unloop.ALL); // leave all loop calls
26                 }
27         );
28         assert (iow.loop !is null);
29         iow.start;
30         auto timerw = new Timer(5.5,
31                 (Timer w, int revents)
32                 {
33                         writefln("timeout, revents = ", revents);
34                         w.loop.unloop(Unloop.ONE); // example syntax
35                 }
36         );
37         assert (timerw.loop !is null);
38         timerw.start;
39         loop.loop;
40 }
41