mirror of
https://github.com/nmap/nmap.git
synced 2025-12-08 13:41:29 +00:00
Remove stupid hacks that are unneeded because of select() magic
This commit is contained in:
@@ -130,17 +130,16 @@ TestSuite = {
|
|||||||
--- Test creation helper function.
|
--- Test creation helper function.
|
||||||
-- Turns a simple function into a test factory.
|
-- Turns a simple function into a test factory.
|
||||||
-- @param test A function that returns true or false depending on test
|
-- @param test A function that returns true or false depending on test
|
||||||
-- @param nargs The number of arguments to the test function
|
|
||||||
-- @param fmt A format string describing the failure condition using the
|
-- @param fmt A format string describing the failure condition using the
|
||||||
-- arguments to the test function
|
-- arguments to the test function
|
||||||
-- @return function that generates tests suitable for use in add_test
|
-- @return function that generates tests suitable for use in add_test
|
||||||
make_test = function(test, blah, fmt)
|
make_test = function(test, fmt)
|
||||||
return function(...)
|
return function(...)
|
||||||
local args={"dummy", ...}
|
local args={...}
|
||||||
local nargs = select("#", ...) + 1
|
local nargs = select("#", ...)
|
||||||
return function(suite)
|
return function(suite)
|
||||||
if not test(table.unpack(args,2,nargs)) then
|
if not test(table.unpack(args,1,nargs)) then
|
||||||
return false, string.format(fmt, table.unpack(args,2,nargs))
|
return false, string.format(fmt, table.unpack(args,1,nargs))
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -152,7 +151,7 @@ end
|
|||||||
-- @return bool True if the value is nil, false otherwise.
|
-- @return bool True if the value is nil, false otherwise.
|
||||||
is_nil = make_test( function(value)
|
is_nil = make_test( function(value)
|
||||||
return value == nil
|
return value == nil
|
||||||
end, 1,
|
end,
|
||||||
"Expected not nil, got %s"
|
"Expected not nil, got %s"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -161,7 +160,7 @@ end, 1,
|
|||||||
-- @return bool True if the value is not nil, false otherwise.
|
-- @return bool True if the value is not nil, false otherwise.
|
||||||
not_nil = make_test( function(value)
|
not_nil = make_test( function(value)
|
||||||
return value ~= nil
|
return value ~= nil
|
||||||
end, 1,
|
end,
|
||||||
"Expected not nil, got %s"
|
"Expected not nil, got %s"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -171,7 +170,7 @@ end, 1,
|
|||||||
-- @return bool True if a == b, false otherwise.
|
-- @return bool True if a == b, false otherwise.
|
||||||
equal = make_test( function(a, b)
|
equal = make_test( function(a, b)
|
||||||
return a == b
|
return a == b
|
||||||
end, 2,
|
end,
|
||||||
"%s not equal to %s"
|
"%s not equal to %s"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -181,7 +180,7 @@ end, 2,
|
|||||||
-- @return bool True if a != b, false otherwise.
|
-- @return bool True if a != b, false otherwise.
|
||||||
not_equal = make_test( function(a, b)
|
not_equal = make_test( function(a, b)
|
||||||
return a ~= b
|
return a ~= b
|
||||||
end, 2,
|
end,
|
||||||
"%s unexpectedly equal to %s"
|
"%s unexpectedly equal to %s"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -190,7 +189,7 @@ end, 2,
|
|||||||
-- @return bool True if value is a boolean and true
|
-- @return bool True if value is a boolean and true
|
||||||
is_true = make_test( function(value)
|
is_true = make_test( function(value)
|
||||||
return value == true
|
return value == true
|
||||||
end, 1,
|
end,
|
||||||
"Expected true, got %s"
|
"Expected true, got %s"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -199,7 +198,7 @@ end, 1,
|
|||||||
-- @return bool True if value is a boolean and false
|
-- @return bool True if value is a boolean and false
|
||||||
is_false = make_test( function(value)
|
is_false = make_test( function(value)
|
||||||
return value == false
|
return value == false
|
||||||
end, 1,
|
end,
|
||||||
"Expected false, got %s"
|
"Expected false, got %s"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -209,7 +208,7 @@ end, 1,
|
|||||||
-- @return bool True if a < b, false otherwise.
|
-- @return bool True if a < b, false otherwise.
|
||||||
lt = make_test( function(a, b)
|
lt = make_test( function(a, b)
|
||||||
return a < b
|
return a < b
|
||||||
end, 2,
|
end,
|
||||||
"%s not less than %s"
|
"%s not less than %s"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -219,7 +218,7 @@ end, 2,
|
|||||||
-- @return bool True if a <= b, false otherwise.
|
-- @return bool True if a <= b, false otherwise.
|
||||||
lte = make_test( function(a, b)
|
lte = make_test( function(a, b)
|
||||||
return a <= b
|
return a <= b
|
||||||
end, 2,
|
end,
|
||||||
"%s not less than %s"
|
"%s not less than %s"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -229,7 +228,7 @@ end, 2,
|
|||||||
-- @return bool True if the length of t is l
|
-- @return bool True if the length of t is l
|
||||||
length_is = make_test( function(t, l)
|
length_is = make_test( function(t, l)
|
||||||
return #t == l
|
return #t == l
|
||||||
end, 2,
|
end,
|
||||||
"Length of %s is not %s"
|
"Length of %s is not %s"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user