Skip to content

Commit

Permalink
test: fix path storage for non-concatable objects
Browse files Browse the repository at this point in the history
When a key of the table to be compared via `tap.test:is_deeply()` is a
non-concatable object (i.e. lightuserdata) its concatenation with the
path prefix raises an error. As a result of this patch the object is
explicitly converted to string to avoid this error.

Needed for tarantool/tarantool#2712

Reviewed-by: Sergey Ostanevich <sergos@tarantool.org>
Reviewed-by: Igor Munkin <imun@tarantool.org>
Signed-off-by: Igor Munkin <imun@tarantool.org>
  • Loading branch information
Buristan authored and igormunkin committed Jun 29, 2022
1 parent bd90464 commit 9ddf356
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/tarantool-tests/tap.lua
Expand Up @@ -166,7 +166,7 @@ local function is_deeply(test, got, expected, message, extra)

for k, v in pairs(got) do
has[k] = true
extra.path = path .. "." .. k
extra.path = path .. "." .. tostring(k)
if not cmpdeeply(v, expected[k], extra) then
return false
end
Expand All @@ -175,7 +175,7 @@ local function is_deeply(test, got, expected, message, extra)
-- Check if expected contains more keys then got.
for k, v in pairs(expected) do
if has[k] ~= true and (extra.strict or v ~= NULL) then
extra.path = path .. "." .. k
extra.path = path .. "." .. tostring(k)
extra.expected = "key (exists): " .. tostring(k)
extra.got = "key (missing): " .. tostring(k)
return false
Expand Down

0 comments on commit 9ddf356

Please sign in to comment.