leaf corcoran %!s(int64=12) %!d(string=hai) anos
pai
achega
0daa0287a5
Modificáronse 1 ficheiros con 34 adicións e 0 borrados
  1. 34 0
      spec/enet_spec.moon

+ 34 - 0
spec/enet_spec.moon

@@ -0,0 +1,34 @@
+
+enet = require "enet"
+
+base_port = 112344
+
+moon = require "moon"
+
+describe "enet", ->
+  it "should host and client", ->
+    host = enet.host_create "localhost:#{base_port}"
+    assert.truthy host
+
+    client = enet.host_create()
+    client\connect "localhost:#{base_port}"
+
+    local host_event, client_event
+    while not client_event or not host_event
+      client_event = client\service(10) or client_event
+      host_event = host\service(10) or host_event
+
+    assert.same "connect", host_event.type
+    assert.same "connect", client_event.type
+
+    host_event.peer\send "Hello World"
+
+    host_event, client_event = nil
+
+    while not client_event
+      client_event = client\service(10) or client_event
+      host_event = host\service(10) or host_event
+
+    assert.same "receive", client_event.type
+    assert.same "Hello World", client_event.data
+