Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buggy test assertion code #30

Closed
wants to merge 1 commit into from

Conversation

foxbenjaminfox
Copy link

@foxbenjaminfox foxbenjaminfox commented Dec 13, 2021

When comparing maps of equal size, the value returned from the do_deep_equal/2 helper is the value of the for loop—a list. That's a problem, given that do_deep_equals/2 is expected to return a boolean: the one place where do_deep_equals/2 is used is as the condition for an if.

When comparing maps of equal size, do_deep_equals/2 will thus always return a truthy value, as all lists are truthy in elixir. This means that the test suite treats any map with the correct number of keys as deeply equal to the result, which causes tests that rightly should fail to pass.

A similar issue arises for lists, where two lists of the same length are always treated as deeply equal, for the same reason.

I have fixed both of these, by piping the for loop evaluates into Enum.all?/1—only if each iteration of the for loop returned true should do_deep_equals/2 return true.

Unfortunately, this PR causes the test suite to fail. That should be expected: the test suite is in fact broken, and tests should be failing with a fixed do_deep_equals/2.

@bitwalker
Copy link
Owner

Thanks! This was fixed in d10ff17

@bitwalker bitwalker closed this Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants