From 009eb7d43d9582856c275ad3b16f7e3ff94209cc Mon Sep 17 00:00:00 2001 From: amelia squires Date: Wed, 16 Apr 2025 13:09:46 -0500 Subject: merge thingy --- tests/old/buffer.lua | 9 ++++++ tests/old/h.lua | 11 ++++++++ tests/old/https.lua | 5 ++++ tests/old/loc.lua | 15 ++++++++++ tests/old/match.lua | 42 ++++++++++++++++++++++++++++ tests/old/net.lua | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/old/net2.lua | 24 ++++++++++++++++ tests/old/nets.lua | 8 ++++++ tests/old/nya.lua | 8 ++++++ tests/old/req.lua | 11 ++++++++ tests/old/s.lua | 15 ++++++++++ tests/old/t.lua | 15 ++++++++++ tests/old/thread.lua | 15 ++++++++++ tests/old/wss.lua | 22 +++++++++++++++ 14 files changed, 278 insertions(+) create mode 100644 tests/old/buffer.lua create mode 100644 tests/old/h.lua create mode 100644 tests/old/https.lua create mode 100644 tests/old/loc.lua create mode 100644 tests/old/match.lua create mode 100644 tests/old/net.lua create mode 100644 tests/old/net2.lua create mode 100644 tests/old/nets.lua create mode 100644 tests/old/nya.lua create mode 100644 tests/old/req.lua create mode 100644 tests/old/s.lua create mode 100644 tests/old/t.lua create mode 100644 tests/old/thread.lua create mode 100644 tests/old/wss.lua (limited to 'tests/old') diff --git a/tests/old/buffer.lua b/tests/old/buffer.lua new file mode 100644 index 0000000..3309aed --- /dev/null +++ b/tests/old/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/old/h.lua b/tests/old/h.lua new file mode 100644 index 0000000..a875b42 --- /dev/null +++ b/tests/old/h.lua @@ -0,0 +1,11 @@ +llib = require "lullaby" +llib.io.print_meta = 1 + +local a = llib.crypto.sha1() + +local b = llib.thread.buffer(a) + +llib.io.pprint(a) +llib.io.pprint(b:get()) +llib.io.pprint((b + "meow"):final()) + diff --git a/tests/old/https.lua b/tests/old/https.lua new file mode 100644 index 0000000..83c5904 --- /dev/null +++ b/tests/old/https.lua @@ -0,0 +1,5 @@ +llby = require"lullaby" + +val, ext = llby.net.srequest("https://amyy.cc/") +llby.io.pprint(val) +llby.io.pprint(ext) diff --git a/tests/old/loc.lua b/tests/old/loc.lua new file mode 100644 index 0000000..d50b9de --- /dev/null +++ b/tests/old/loc.lua @@ -0,0 +1,15 @@ +llby = require "lullaby" + +local nya = "mya" +uwu = "bye" +local _o = _G +_G.ooo = "mya" +print(_o.ooo) +local owo = "hi" + +function a() + local meo = "a" + llby.test.stack_dump() +end + +a() diff --git a/tests/old/match.lua b/tests/old/match.lua new file mode 100644 index 0000000..000b1e7 --- /dev/null +++ b/tests/old/match.lua @@ -0,0 +1,42 @@ +llb = require "lullaby" + +function test(a, b, match, expect) + res, out = llb.test._match(a, b) + + if res == 0 and res == match then return end + + if res ~= match then + return llb.io.error(a..":"..b.." res("..res..") != expected") + end + + if res == 0 then + return llb.io.error(a..":"..b.." res == match") + end + + if llb.array.len(out) ~= llb.array.len(expect) then + return llb.io.error("out != expect") + end + + for i, v in ipairs(expect) do + if v ~= out[i] then + return llb.io.error("out != expect") + end + end +end + +test("/{test}/","/name/", 1, {test="name"}) +test("/", "/wawawawawawaw", 0) +test("*","/wdejowe/wde", 1, {}) +test("/*/{hello}/{meow}/end","/blah/blah/hii/end", 1, {hello="blah", meow="hii"}) +test("/*/*/{test}/*/*/end/*/real","/a/b/testing/d/e/end/f/real", 1, {test="testing"}) +test("/*/a/b/end/{word}","/w/o/m/p/a/b/end/meow", 1, {word="meow"}) +test("*", "meow/meow/meow", 1, {}) +test("{meow}", "owo", 1, {meow="owo"}) +test("/{meow}", "/owo", 1, {meow="owo"}) +test("{meow}", "/", 0) +test("/{meow}", "/", 0) +test("/*/", "/test", 0) +test("/{meow}/", "/aw", 0) +--i dont know if this should be valid, but idc +test("/{meow}/", "//", 1, {meow=""}) + diff --git a/tests/old/net.lua b/tests/old/net.lua new file mode 100644 index 0000000..f5e57f9 --- /dev/null +++ b/tests/old/net.lua @@ -0,0 +1,78 @@ +--yes, this is kinda a mess of requires, just proof it works:3 +net = require "lullaby.net" +local io = require "lullaby.io" +local crypto = require "lullaby.crypto" + +io.max_depth = 5 + +sleep = function(a) + local sec = tonumber(os.clock() + a); + while (os.clock() < sec) do + end +end + +net.listen( + function(server) + + io.pprint("online") + _G.server = server + + server:POST("/{name}", function(res, req) + eroifjeor() + --print("name is "..req.name) + print("name") + io.pprint(req.parameters) + res:stop() + end) + + server:all("/{name}/nya/{user}", function(res, req) + --print("name is "..req.name) + print("name user") + io.pprint(req.parameters) + end) + + server:all("*", function(res, req) + print("all") + io.pprint(req.parameters) + end) + + server:all("/{name}/user/*/{id}", function(res, req) + print("owo") + io.pprint(req.parameters) + + end) + + server:all("/", function(res, req) + b = crypto.md5("hello") + + res:send(b) + + a = req:roll() + + while a > -1 do + a = req:roll() + print(req._bytes .. "/" .. req["Content-Length"]) + end + io.pprint(req) + + end) + + server:GET("/aa", function(res, req) + --res.header["Content-Type"] = "text/plain" + res:sendfile("readme.md", {attachment=true}) + end) + + server:GET("/test55", function(res, req) + res.Code = 403 + res:send("

you would never

") + end) + + server:GET("/error", function(res, req) + res.a.a.a.a() + end) + + + + end, + arg[1] +) diff --git a/tests/old/net2.lua b/tests/old/net2.lua new file mode 100644 index 0000000..bb69051 --- /dev/null +++ b/tests/old/net2.lua @@ -0,0 +1,24 @@ +--(this is in tests/net2.lua) +net = require "lullaby.net" +local crypto = require "lullaby.crypto" +local port = 8080 +MAX_LENGTH = 2048 + +net.listen(function(server) + + --listen to post requests at localhost:8080 (root directory) + server:POST("/", function(res, req) + --creates a sha0 hash object + local hash = crypto.sha0() + --loads an extra 2048 characters from the request body (the body is not guaranteed to be >= 2048 characters, reasoning in docs) + req:roll(MAX_LENGTH) + + --incremental hashes allow updating via addition, in this case adding the body and getting a string from it + hash = (hash + req.Body):final() + print(hash, crypto) + --send the hash to the client, closes connection, but thread is live until it ends + res:send(hash) + end) + +end, port) + diff --git a/tests/old/nets.lua b/tests/old/nets.lua new file mode 100644 index 0000000..a356539 --- /dev/null +++ b/tests/old/nets.lua @@ -0,0 +1,8 @@ +llby = require"lullaby" + +llby.net.listen(function(server) + server:GET("/", function(res, req) + res:sendfile("license.md") + --res:sendfile("../awa/static/volcarona.gif") + end) +end, 8888) diff --git a/tests/old/nya.lua b/tests/old/nya.lua new file mode 100644 index 0000000..ca5299c --- /dev/null +++ b/tests/old/nya.lua @@ -0,0 +1,8 @@ +llby = require "lullaby" + +llby.net.listen(function(server) + server:GET("/", function(res, req) + print("hi") + llby.io.pprint(req) + end) +end, 8887) diff --git a/tests/old/req.lua b/tests/old/req.lua new file mode 100644 index 0000000..9eb4cf3 --- /dev/null +++ b/tests/old/req.lua @@ -0,0 +1,11 @@ +local awa = require "lullaby" + +print(awa.net.srequest("amyy.cc", "/", "meow").content) + +--awa.net.srequest("example.com", "/", "meow") + +--[[ + +net.srequest("example.com", "/", {key="meow"}, {Header="value"}) + +]]-- diff --git a/tests/old/s.lua b/tests/old/s.lua new file mode 100644 index 0000000..ae84e25 --- /dev/null +++ b/tests/old/s.lua @@ -0,0 +1,15 @@ +local t = function (a) end + +llib = require "llib" + +local a = llib.crypto.md5() +--llib.io.pprint(_ENV.a) + +for i = 1,200 do + awa = function(a) end + llib.thread.async(awa):await() +end + +if a:final() ~= "d41d8cd98f00b204e9800998ecf8427e" then + print(a:final()) +end diff --git a/tests/old/t.lua b/tests/old/t.lua new file mode 100644 index 0000000..09ee15d --- /dev/null +++ b/tests/old/t.lua @@ -0,0 +1,15 @@ +a = require "lullaby" + +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() diff --git a/tests/old/thread.lua b/tests/old/thread.lua new file mode 100644 index 0000000..8b7de88 --- /dev/null +++ b/tests/old/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") + + diff --git a/tests/old/wss.lua b/tests/old/wss.lua new file mode 100644 index 0000000..f9ecfbd --- /dev/null +++ b/tests/old/wss.lua @@ -0,0 +1,22 @@ +llby = require("lullaby") + +local ws, error = llby.net.wss("echo.websocket.org:4432") + +if ws == nil then + print(error) + os.exit(12) +end + +print(ws) + +for i=1,10 do + local c = ws:read().content + print(c) + ws:write(c.."a") +end + +ws:close() +ws:close() + +--ws:ping() +--add onclose? -- cgit v1.2.3