diff options
author | Aki <please@ignore.pl> | 2024-02-16 15:59:40 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-02-16 15:59:40 +0100 |
commit | 868a808d2a9624df12555af8313995f86102a4c4 (patch) | |
tree | ef5c4f983895fa4db96b2a7373f1ba7d77344a56 | |
parent | 392287e65104e54a6d3724ce64be6b2d709ca0e0 (diff) | |
download | lua-srcinfo-868a808d2a9624df12555af8313995f86102a4c4.zip lua-srcinfo-868a808d2a9624df12555af8313995f86102a4c4.tar.gz lua-srcinfo-868a808d2a9624df12555af8313995f86102a4c4.tar.bz2 |
-rw-r--r-- | srcinfo.lua | 2 | ||||
-rw-r--r-- | srcinfo_spec.lua | 20 |
2 files changed, 15 insertions, 7 deletions
diff --git a/srcinfo.lua b/srcinfo.lua index 058b9c6..c038641 100644 --- a/srcinfo.lua +++ b/srcinfo.lua @@ -43,7 +43,7 @@ local comment = lpeg.Cc"comment" * whitespace * lpeg.P"#" * lpeg.C(rest) local empty = lpeg.Cc"empty" * whitespace local invalid = lpeg.Cc"invalid" * lpeg.C(rest) local line = lpeg.Carg(1) * (definition + comment + empty + invalid) / apply * newline -local capture = lpeg.Ct(line^0) * -lpeg.P(1) +local capture = lpeg.Ct(line^0) * whitespace * -lpeg.P(1) local diff --git a/srcinfo_spec.lua b/srcinfo_spec.lua index b0b574b..2312905 100644 --- a/srcinfo_spec.lua +++ b/srcinfo_spec.lua @@ -2,15 +2,23 @@ local srcinfo = require "srcinfo" local stx = require "pl.stringx" -describe("Parses empty content in", function() - it("pkgname mode (default)", function() - local pkgs = srcinfo"" - assert.are.same({}, pkgs) +describe("Empty strings ared parsed successfully in", function() + it("pkgname mode", function() + assert.are.same({}, srcinfo"") + assert.are.same({}, srcinfo"\n") + assert.are.same({}, srcinfo" ") + assert.are.same({}, srcinfo"\n ") + assert.are.same({}, srcinfo" \n") + assert.are.same({}, srcinfo" \n ") end) it("pkgbase mode", function() - local bases = srcinfo("", {mode="pkgbase"}) - assert.are.same({}, bases) + assert.are.same({}, srcinfo("", {mode="pkgbase"})) + assert.are.same({}, srcinfo("\n", {mode="pkgbase"})) + assert.are.same({}, srcinfo(" ", {mode="pkgbase"})) + assert.are.same({}, srcinfo("\n ", {mode="pkgbase"})) + assert.are.same({}, srcinfo(" \n", {mode="pkgbase"})) + assert.are.same({}, srcinfo(" \n ", {mode="pkgbase"})) end) end) |