Skip to content

Commit 4779dd6

Browse files
committed
fix test_dir param and allow userdata in table_eq
1 parent 6a95308 commit 4779dd6

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

test/main.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ local done_command = utils.processArgsGetopt({...}, {
3737
{'h', 'help', handler=function() help = true end},
3838
{'n', 'nocache', handler=function() nocache = true end},
3939
{'d', 'test_dir', hasArg=true,
40-
handler=function(arg) mode_filter = arg:split(',') end},
40+
handler=function(arg) test_dir = arg end},
4141
{'m', 'modes', hasArg=true,
4242
handler=function(arg) mode_filter = arg:split(',') end},
4343
{'t', 'tests', hasArg=true,
@@ -127,8 +127,9 @@ local function table_eq_recurse(a, b, keys, known_eq)
127127
return true
128128
end
129129
function expect.table_eq(a, b, comment)
130-
if type(a) ~= 'table' or type(b) ~= 'table' then
131-
return false, comment, 'both operands to table_eq must be tables'
130+
if (type(a) ~= 'table' and type(a) ~= 'userdata') or
131+
(type(b) ~= 'table' and type(b) ~= 'userdata') then
132+
return false, comment, 'operands to table_eq must be tables or userdata'
132133
end
133134
local keys, known_eq = {}, {}
134135
local matched, keys_at_diff, diff = table_eq_recurse(a, b, keys, known_eq)

test/test.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ function test.table_eq()
88
expect.true_(expect_raw.table_eq({{'a', k='val'}, 'b'},
99
{{'a', k='val'}, 'b'}))
1010

11+
expect.false_(expect_raw.table_eq(nil, nil)) -- operands must be non-nil
12+
expect.false_(expect_raw.table_eq({}, nil))
13+
expect.false_(expect_raw.table_eq(nil, {}))
1114
expect.false_(expect_raw.table_eq({}, {''}))
1215
expect.false_(expect_raw.table_eq({''}, {}))
1316
expect.false_(expect_raw.table_eq({'a', {}}, {'a'}))

0 commit comments

Comments
 (0)