Skip to content

Fix Enum tests for maps in OTP26 #12405

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

Merged
merged 1 commit into from
Feb 16, 2023

Conversation

sabiwara
Copy link
Contributor

Make Enum tests for maps independent of Map ordering, in order to fix tests for OTP26. (see also: #12404)

seed1 = {1406, 407_414, 139_258}
seed2 = {1406, 421_106, 567_597}
:rand.seed(:exsss, seed1)
assert Enum.take_random(map, 1) == [c: 3]
assert Enum.take_random(map, 1) == [x3]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took this approache here, but I'm not sure if it's the best here. Maybe these tests could actually be removed and more property-based testing could be added in StreamData?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are silly in a way but important because we often have special clauses for lists, so we need to test the enum implementations. The other option is to use MapSet, but they don't guarantee order as well, so...

If we had a queue :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see!
If we want something that's a) ordered and b) not optimized (rules out ranges), I think streams could be a nice candidate? Something like:
https://github.com/elixir-lang/elixir/compare/main...sabiwara:elixir:use-stream-for-enum-tests?expand=1

If there's interest, I can open up a PR.

Noted for the queue ;) (but this might be optimizeable too)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, streams are an option and we have tests with them too. But I would only add tests, the changes you did are great.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So basically keep EnumTest.Map but add EnumTest.Stream as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If necessary, surely, but i assume we are well covered? :)

@josevalim josevalim merged commit 7f2c927 into elixir-lang:main Feb 16, 2023
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

josevalim pushed a commit that referenced this pull request Feb 16, 2023
@sabiwara sabiwara deleted the fix-map-enum-tests-otp26 branch February 16, 2023 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants