-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.lua
48 lines (33 loc) · 1.24 KB
/
test.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
local ev = require "levent"
print (assert (ev, "module"))
print (assert (ev.fdfromfile (io.input())==0, "stdin == fd 0"))
print (assert (ev.fdfromfile (io.output())==1, "stdout == fd 1"))
print (assert (ev.newbase, "ev.newbase"))
local base = ev.newbase()
print (assert (base, "base"))
print (assert (base.newevent, "base.newevent"))
print (assert (type (base.newevent)=="function", "base.newevent()"))
local ncals = 0
local rdevent = base:newevent (0,
function (a,b)
print ("cb:",a,b,ncals)
ncals = ncals+1
end)
print ("rdevent:", rdevent)
print (assert (rdevent, "rdevent"))
print (assert (rdevent:start(), "start"))
print (assert (base.loop, "base.loop"))
print "loop inicial"
print (assert (base:loop(1), "base.loop()"))
print (assert (io.read("*l"), "io.read(*l)"))
print (assert (ncals==1, "ncals==1"))
print (assert (rdevent:stop(), "stop"))
print "segundo loop, luego de ev:stop()"
print (assert (base:loop(1), "base.loop()"))
print (assert (rdevent:start(), "start"))
print "tercer loop, evento reactivado"
print (assert (base:loop(1), "base.loop()"))
print (assert (io.read("*l"), "io.read(*l)"))
print (assert (rdevent:delete(), "delete"))
-- print (assert (ev.addfd, "ev.addfd"))
-- print (assert (type(ev.addfd)=="function", "ev.addfd()"))