From bd405bc6f3104ba7c6d41c42561975d73fd81134 Mon Sep 17 00:00:00 2001 From: amelia squires Date: Wed, 11 Sep 2024 00:02:08 -0500 Subject: add res:stop --- tests/net.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/net.lua b/tests/net.lua index 90a18c3..d1b5369 100644 --- a/tests/net.lua +++ b/tests/net.lua @@ -18,10 +18,11 @@ net.listen( io.pprint("online") _G.server = server - server:all("/{name}", function(res, req) + server:POST("/{name}", function(res, req) --print("name is "..req.name) print("name") io.pprint(req.paramaters) + res:stop() end) server:all("/{name}/nya/{user}", function(res, req) -- cgit v1.2.3 From 602818b895fec710b0534b0b8fa7f5e1f57203c2 Mon Sep 17 00:00:00 2001 From: amelia squires Date: Mon, 16 Sep 2024 12:16:29 -0500 Subject: fix _copy and mem leaks --- tests/hash.lua | 22 +++++++++++++++++++++- tests/t.lua | 5 +++++ tests/thread.lua | 15 +++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/t.lua create mode 100644 tests/thread.lua (limited to 'tests') diff --git a/tests/hash.lua b/tests/hash.lua index 60d33a8..d314167 100644 --- a/tests/hash.lua +++ b/tests/hash.lua @@ -1,5 +1,7 @@ llib = require "lullaby" +--llib.io.log = function() end + local hashes_working = 0 local hashes_failed = 0 local functions_working = 0 @@ -14,6 +16,8 @@ function test(name,b,exp,oargs) local hash5 local hash6 local hash7 + local hash8 + local hash9 local add = "" if oargs == nil then hash = llib.crypto[name](b) @@ -28,13 +32,29 @@ function test(name,b,exp,oargs) hash5 = llib.crypto[name]() hash6 = hash5 + b; hash6 = hash6:final() - hash5 = hash5:update(b):final() + hash5 = hash5:update(b):final() + hash7 = llib.crypto[name]() else hash2 = llib.crypto[name](table.unpack(oargs)):update(b):final() hash5 = llib.crypto[name](table.unpack(oargs)) hash6 = hash5 + b; hash6 = hash6:final() hash5 = hash5:update(b):final() + hash7 = llib.crypto[name](table.unpack(oargs)) + end + + hash8 = hash7 + "test" + hash9 = hash8:final() + hash7 = hash7:update("meo"):final() + hash8 = hash8:final() + + if hash8 ~= hash9 then + fail = true + functions_failed = functions_failed + 1 + llib.io.error(name.." __copy not working") + else + functions_working = functions_working + 1 + llib.io.log(name.." __copy working") end if(hash5 ~= exp) then diff --git a/tests/t.lua b/tests/t.lua new file mode 100644 index 0000000..9c71c61 --- /dev/null +++ b/tests/t.lua @@ -0,0 +1,5 @@ +a = require "lullaby" + +o = a.crypto.sha224() +--o:update("me") +--print(o:final()) diff --git a/tests/thread.lua b/tests/thread.lua new file mode 100644 index 0000000..8b7de88 --- /dev/null +++ b/tests/thread.lua @@ -0,0 +1,15 @@ +llby = require "lullaby" + +llby.thread.async(function(res, rej) + print("hi") + a = llby.crypto.sha512() + a:update("hi") + b = a + "meow" + print((b + "hi"):final()) + print((a:update("hi")):final()) + print((b + "hi"):final()) +end) + +os.execute("sleep 1") + + -- cgit v1.2.3 From fe33c0e979ebfc41c3eb9f561589f0d5d8810aaf Mon Sep 17 00:00:00 2001 From: amelia squires Date: Sun, 29 Sep 2024 02:49:05 -0500 Subject: docs n stuff --- tests/buffer.lua | 9 +++++++++ tests/net.lua | 2 +- tests/t.lua | 16 +++++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 tests/buffer.lua (limited to 'tests') diff --git a/tests/buffer.lua b/tests/buffer.lua new file mode 100644 index 0000000..3309aed --- /dev/null +++ b/tests/buffer.lua @@ -0,0 +1,9 @@ +llby = require "lullaby" + +b = llby.thread.buffer(llby.crypto.md5()) + +print(b.update(b:get(), "meow"):final()) +print(b.update(b:get(), "meow"):final()) +b:mod(function(this) return this:update("meow") end) +print(b.update(b:get(), "meow"):final()) + diff --git a/tests/net.lua b/tests/net.lua index d1b5369..e389fb0 100644 --- a/tests/net.lua +++ b/tests/net.lua @@ -58,7 +58,7 @@ net.listen( end) server:GET("/aa", function(res, req) - res.header["Content-Type"] = "text/plain" + --res.header["Content-Type"] = "text/plain" res:sendfile("readme.md") end) diff --git a/tests/t.lua b/tests/t.lua index 9c71c61..09ee15d 100644 --- a/tests/t.lua +++ b/tests/t.lua @@ -1,5 +1,15 @@ a = require "lullaby" -o = a.crypto.sha224() ---o:update("me") ---print(o:final()) +b = coroutine.create(function() + os.execute("sleep 2") + print("co") +end) + +c = a.thread.async(function(res, req) + coroutine.resume(b) +end) + +os.execute("sleep 0.5") +print("owo") + +c:await() -- cgit v1.2.3