lunarmodules / luassert

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

Combining same() and near() #177

Closed AndreasMatthias closed 3 years ago

AndreasMatthias commented 3 years ago

I'm using same() to compare tables, but I'd like to use near() for numbers inside this table. Is it possible to combine same() and near()?

Similary to

assert.near(2.3, 2.4, 0.2)

I'd like to do

assert.nearly_same(
   {a = 2.3, b = 'x'},
   {a = 2.4, b = 'x'},
   0.2
)
Tieske commented 3 years ago

you'd have to write your own assertion for that.