lunarmodules/luassert

Feature request: parameter to only show differences between tables

Alloyed opened this issue · 1 comments

So I'm turning a real-world bug into a busted test right now, where my input data is a large 2d array. Naively using assert.are.same() leads to a silly amount of output, effectively printing the same giant array twice, in full. I'm settling on rewriting the test like so

for y, row in ipairs(expected) do
  for x, cell in ipairs(row) do
    print(x, y)
    assert.are.same(input[y][x], cell)
  end
end

but this is obviously clunky. Since all I need are the differences between each table, it'd be nice to instead have a parameter that just says "elide all unchanged fields below depth N", in the same way deeply nested tables can be elided.

That sounds like a great feature, I haven't looked at that code in a long time so I have no idea how hard it would be. Pull requests welcome!