fix test_dir param and allow userdata in table_eq

develop
myk002 2021-03-06 05:02:05 -08:00
parent 6a95308123
commit 4779dd678d
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 7 additions and 3 deletions

@ -37,7 +37,7 @@ local done_command = utils.processArgsGetopt({...}, {
{'h', 'help', handler=function() help = true end},
{'n', 'nocache', handler=function() nocache = true end},
{'d', 'test_dir', hasArg=true,
handler=function(arg) mode_filter = arg:split(',') end},
handler=function(arg) test_dir = arg end},
{'m', 'modes', hasArg=true,
handler=function(arg) mode_filter = arg:split(',') end},
{'t', 'tests', hasArg=true,
@ -127,8 +127,9 @@ local function table_eq_recurse(a, b, keys, known_eq)
return true
end
function expect.table_eq(a, b, comment)
if type(a) ~= 'table' or type(b) ~= 'table' then
return false, comment, 'both operands to table_eq must be tables'
if (type(a) ~= 'table' and type(a) ~= 'userdata') or
(type(b) ~= 'table' and type(b) ~= 'userdata') then
return false, comment, 'operands to table_eq must be tables or userdata'
end
local keys, known_eq = {}, {}
local matched, keys_at_diff, diff = table_eq_recurse(a, b, keys, known_eq)

@ -8,6 +8,9 @@ function test.table_eq()
expect.true_(expect_raw.table_eq({{'a', k='val'}, 'b'},
{{'a', k='val'}, 'b'}))
expect.false_(expect_raw.table_eq(nil, nil)) -- operands must be non-nil
expect.false_(expect_raw.table_eq({}, nil))
expect.false_(expect_raw.table_eq(nil, {}))
expect.false_(expect_raw.table_eq({}, {''}))
expect.false_(expect_raw.table_eq({''}, {}))
expect.false_(expect_raw.table_eq({'a', {}}, {'a'}))