aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/match.lua37
-rw-r--r--tests/net.lua13
2 files changed, 49 insertions, 1 deletions
diff --git a/tests/match.lua b/tests/match.lua
new file mode 100644
index 0000000..d9c1533
--- /dev/null
+++ b/tests/match.lua
@@ -0,0 +1,37 @@
+llb = require "lullaby"
+
+function test(a, b, match, expect)
+ res, out = llb.test._match(a, b)
+
+ if res ~= match then
+ return llb.io.error("res != match")
+ end
+
+ if res == 0 then return 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
+ llb.io.pprint(out)
+end
+
+test("/{test}/","/name/", 1, {test="name"})
+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)
+
+
+
+
diff --git a/tests/net.lua b/tests/net.lua
index fdb17d4..940e2fb 100644
--- a/tests/net.lua
+++ b/tests/net.lua
@@ -19,12 +19,23 @@ net.listen(
_G.server = server
server:all("/{name}", function(res, req)
- print("name is "..req.name)
+ --print("name is "..req.name)
+ print("name")
end)
+
+ server:all("/{name}/nya/{user}", function(res, req)
+ --print("name is "..req.name)
+ print("name id user")
+ end)
+
server:all("*", function(res, req)
print("all")
end)
+ server:all("/{name}/user/*/{id}", function(res, req)
+ print("owo")
+ end)
+
server:all("/", function(res, req)
b = crypto.md5("hello")