lunarmodules / luassert

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

`assert.same` has poor performance and only compares depth of back references #182

Open appgurueu opened 2 years ago

appgurueu commented 2 years ago

More performant implementation that checks whether a reference mapping exists: https://github.com/minetest/minetest/blob/36c8e5a7f18d7254d9f8991cbc8cd5dd36c5f577/builtin/common/tests/serialize_spec.lua#L9-L37

Perhaps this should be added as a new assertion in order to not break backwards compat; either way my fuzzing seems to reveal that for complex circular structures assert.same has very poor (presumably exponentially poor) performance.