:pparse() should still raise an error if it is caused by misconfiguration

This commit is contained in:
mpeterv
2014-02-18 15:35:58 +04:00
parent a0fe631b08
commit 3a80e0179b
2 changed files with 8 additions and 0 deletions

View File

@@ -16,4 +16,11 @@ describe("tests related to :pparse()", function()
assert.is_false(ok) assert.is_false(ok)
assert.equal("too few arguments", errmsg) assert.equal("too few arguments", errmsg)
end) end)
it("still raises an error if it is caused by misconfiguration", function()
local parser = Parser()
parser:option "--foo"
:count "a lot"
assert.has_error(function() parser:pparse{} end)
end)
end) end)

View File

@@ -778,6 +778,7 @@ function Parser:pparse(args)
if ok then if ok then
return true, result return true, result
else else
assert(errmsg, result)
return false, errmsg return false, errmsg
end end
end end