diff options
| author | amelia squires <[email protected]> | 2025-04-16 13:09:46 -0500 |
|---|---|---|
| committer | amelia squires <[email protected]> | 2025-04-16 13:09:46 -0500 |
| commit | 009eb7d43d9582856c275ad3b16f7e3ff94209cc (patch) | |
| tree | 6d1f5ea000a6d72164a5b6e05b68dfbe0371ae06 /tests/old/match.lua | |
| parent | dd7a8af4050454c3901987bff24a77334f892cc4 (diff) | |
merge thingy
Diffstat (limited to 'tests/old/match.lua')
| -rw-r--r-- | tests/old/match.lua | 42 |
1 files changed, 42 insertions, 0 deletions
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=""}) + |
