lunarmodules / luassert

Assertion library for Lua
MIT License
202 stars 77 forks source link

Feature request: parameter to only show differences between tables #143

Closed Alloyed closed 5 years ago

Alloyed commented 7 years ago

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.

DorianGray commented 7 years ago

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!