lunarmodules / luassert

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

util.deepcompare fails with __pairs #127

Closed daurnimator closed 9 years ago

daurnimator commented 9 years ago

I have 2 objects that have a __pairs metamethod on them. When I try and use assert.same on them, they return false, as they don't have an __index for the 'keys' returned by my __pairs.

One potential fix is to use next, t instead of pairs(t) so that __pairs is not used. An alternative solution is to use pairs() to iterate through each object, building a temporary list of pairs, and then comparing those lists.

daurnimator commented 9 years ago

ps, this causes really confusing error message in busted, see e.g. https://travis-ci.org/daurnimator/lua-http/jobs/71623063

o-lim commented 9 years ago

PR #128 should fix this. Updated util.deepcompare to use next, t, nil.

daurnimator commented 9 years ago

Looks good :)

daurnimator commented 9 years ago

@DorianGray could you make a release with this fix in it? I'd love to see my CI tests passing again :)