Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

Option to test for deep equality #46

Open
christopherhafke opened this issue Jul 17, 2019 · 2 comments
Open

Option to test for deep equality #46

christopherhafke opened this issue Jul 17, 2019 · 2 comments

Comments

@christopherhafke
Copy link

If one wishes to test for deep equality (i.e. recursive equality), one currently has to supply their own deep equality function and write something like
expect(deepEqual(value1, value2)).to.equal(true)
An option to test for deep equality between two tables, especially one that can alert where the two tables differ if they do, would be very helpful.

@LPGhatguy
Copy link
Contributor

For using a custom deepEqual function, I'd highly recommend using assert instead of expect, since it lets you have a custom error message that can be returned by your comparison function.

I'm hesitant to add more assertion features into TestEZ's expectation library, especially as they become a little more opinionated. Deep equality is a good example of something that can vary based on intent; it isn't applicable to things like Roact objects, and falls apart for cases where we use tables for their identity on purpose!

If anything, I'd like to start moving towards making it easier to make TestEZ itself smaller, and introduce libraries to fix opinionated cases like this one.

@christopherhafke
Copy link
Author

christopherhafke commented Jul 17, 2019

That's fair. There is the option to parameterize the deepEqual function to allow for variety in how it should be used (e.g. for metatables, self references, maximal recursion depths etc), but I can see how that might make the framework less lightweight.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants