fixed tests: all printed data is quoted

This commit is contained in:
mpeterv
2014-01-25 12:46:42 +04:00
parent 23de82cab0
commit c0039106f3
5 changed files with 15 additions and 15 deletions

View File

@@ -75,9 +75,9 @@ Features:
parser:command "install"
parser:parse{"--form", "there"}
-- Error: unknown option --form
-- Did you mean --from?
-- Error: unknown option '--form'
-- Did you mean '--from'?
parser:parse{"isntall"}
-- Error: unknown command isntall
-- Did you mean install?
-- Error: unknown command 'isntall'
-- Did you mean 'install'?

View File

@@ -88,7 +88,7 @@ describe("tests related to positional arguments", function()
local parser = argparse.parser()
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)
it("handles too few arguments with one argument correctly", function()

View File

@@ -18,7 +18,7 @@ describe("tests related to commands", function()
local args = parser:parse{"install", "-q"}
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)
it("allows to continue passing old options", function()
@@ -57,6 +57,6 @@ describe("tests related to commands", function()
local parser = argparse.parser "name"
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)

View File

@@ -19,7 +19,7 @@ describe("tests related to converters", function()
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)
it("second return value is used as error message", function()

View File

@@ -185,10 +185,10 @@ describe("tests related to options", function()
it("handles unknown options correctly", function()
local parser = argparse.parser()
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{"-s"} end, "unknown option -s")
assert.has_error(function() parser:parse{"-slocalhost"} end, "unknown option -s")
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{"-s"} end, "unknown option '-s'")
assert.has_error(function() parser:parse{"-slocalhost"} end, "unknown option '-s'")
end)
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()
local parser = argparse.parser()
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)
it("handles too many invocations correctly", function()
@@ -209,7 +209,7 @@ describe("tests related to options", function()
count = 1,
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)
it("handles too few invocations correctly", function()
@@ -217,7 +217,7 @@ describe("tests related to options", function()
parser:option("-f", "--foo", {
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)