mirror of
https://github.com/TangentFoxy/argparse.git
synced 2025-07-28 02:52:20 +00:00
fixed tests: all printed data is quoted
This commit is contained in:
@@ -75,9 +75,9 @@ Features:
|
|||||||
parser:command "install"
|
parser:command "install"
|
||||||
|
|
||||||
parser:parse{"--form", "there"}
|
parser:parse{"--form", "there"}
|
||||||
-- Error: unknown option --form
|
-- Error: unknown option '--form'
|
||||||
-- Did you mean --from?
|
-- Did you mean '--from'?
|
||||||
|
|
||||||
parser:parse{"isntall"}
|
parser:parse{"isntall"}
|
||||||
-- Error: unknown command isntall
|
-- Error: unknown command 'isntall'
|
||||||
-- Did you mean install?
|
-- Did you mean 'install'?
|
||||||
|
@@ -88,7 +88,7 @@ describe("tests related to positional arguments", function()
|
|||||||
local parser = argparse.parser()
|
local parser = argparse.parser()
|
||||||
parser:argument "foo"
|
parser:argument "foo"
|
||||||
|
|
||||||
assert.has_error(function() parser:parse{"-q"} end, "unknown option -q")
|
assert.has_error(function() parser:parse{"-q"} end, "unknown option '-q'")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("handles too few arguments with one argument correctly", function()
|
it("handles too few arguments with one argument correctly", function()
|
||||||
|
@@ -18,7 +18,7 @@ describe("tests related to commands", function()
|
|||||||
|
|
||||||
local args = parser:parse{"install", "-q"}
|
local args = parser:parse{"install", "-q"}
|
||||||
assert.same({install = true, quiet = true}, args)
|
assert.same({install = true, quiet = true}, args)
|
||||||
assert.has_error(function() parser:parse{"-q", "install"} end, "unknown option -q")
|
assert.has_error(function() parser:parse{"-q", "install"} end, "unknown option '-q'")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("allows to continue passing old options", function()
|
it("allows to continue passing old options", function()
|
||||||
@@ -57,6 +57,6 @@ describe("tests related to commands", function()
|
|||||||
local parser = argparse.parser "name"
|
local parser = argparse.parser "name"
|
||||||
local install = parser:command "install"
|
local install = parser:command "install"
|
||||||
|
|
||||||
assert.has_error(function() parser:parse{"isntall"} end, "unknown command isntall")
|
assert.has_error(function() parser:parse{"isntall"} end, "unknown command 'isntall'")
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -19,7 +19,7 @@ describe("tests related to converters", function()
|
|||||||
args = "+"
|
args = "+"
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.has_error(function() parser:parse{"foo", "bar", "baz"} end, "malformed argument foo")
|
assert.has_error(function() parser:parse{"foo", "bar", "baz"} end, "malformed argument 'foo'")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("second return value is used as error message", function()
|
it("second return value is used as error message", function()
|
||||||
|
@@ -185,10 +185,10 @@ describe("tests related to options", function()
|
|||||||
|
|
||||||
it("handles unknown options correctly", function()
|
it("handles unknown options correctly", function()
|
||||||
local parser = argparse.parser()
|
local parser = argparse.parser()
|
||||||
assert.has_error(function() parser:parse{"--server"} end, "unknown option --server")
|
assert.has_error(function() parser:parse{"--server"} end, "unknown option '--server'")
|
||||||
assert.has_error(function() parser:parse{"--server=localhost"} end, "unknown option --server")
|
assert.has_error(function() parser:parse{"--server=localhost"} end, "unknown option '--server'")
|
||||||
assert.has_error(function() parser:parse{"-s"} end, "unknown option -s")
|
assert.has_error(function() parser:parse{"-s"} end, "unknown option '-s'")
|
||||||
assert.has_error(function() parser:parse{"-slocalhost"} end, "unknown option -s")
|
assert.has_error(function() parser:parse{"-slocalhost"} end, "unknown option '-s'")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("handles too many arguments correctly", function()
|
it("handles too many arguments correctly", function()
|
||||||
@@ -200,7 +200,7 @@ describe("tests related to options", function()
|
|||||||
it("doesn't accept GNU-like long options when it doesn't need arguments", function()
|
it("doesn't accept GNU-like long options when it doesn't need arguments", function()
|
||||||
local parser = argparse.parser()
|
local parser = argparse.parser()
|
||||||
parser:flag("-q", "--quiet")
|
parser:flag("-q", "--quiet")
|
||||||
assert.has_error(function() parser:parse{"--quiet=very_quiet"} end, "option --quiet doesn't take arguments")
|
assert.has_error(function() parser:parse{"--quiet=very_quiet"} end, "option '--quiet' doesn't take arguments")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("handles too many invocations correctly", function()
|
it("handles too many invocations correctly", function()
|
||||||
@@ -209,7 +209,7 @@ describe("tests related to options", function()
|
|||||||
count = 1,
|
count = 1,
|
||||||
overwrite = false
|
overwrite = false
|
||||||
})
|
})
|
||||||
assert.has_error(function() parser:parse{"-qq"} end, "option -q must be used at most 1 times")
|
assert.has_error(function() parser:parse{"-qq"} end, "option '-q' must be used at most 1 times")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("handles too few invocations correctly", function()
|
it("handles too few invocations correctly", function()
|
||||||
@@ -217,7 +217,7 @@ describe("tests related to options", function()
|
|||||||
parser:option("-f", "--foo", {
|
parser:option("-f", "--foo", {
|
||||||
count = "3-4"
|
count = "3-4"
|
||||||
})
|
})
|
||||||
assert.has_error(function() parser:parse{"-fFOO", "-fBAR"} end, "option -f must be used at least 3 times")
|
assert.has_error(function() parser:parse{"-fFOO", "-fBAR"} end, "option '-f' must be used at least 3 times")
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user