Skip to content

Fix BiMap.put/3 mapping update issue #5

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 2 commits into from
Jun 17, 2019
Merged

Fix BiMap.put/3 mapping update issue #5

merged 2 commits into from
Jun 17, 2019

Conversation

NullOranje
Copy link
Contributor

Wrote a patch to resolve the issue identified in #4. It simply removes any existing reverse-mappings prior to updating the BiMap. Added a test to ensure that BiMap.put/3 updates correctly.

Because of failures with the random StreamData, I modified the it puts items into bimaps test to use a single type when generating the initial map. Keys are now always atoms, and values are always integers.

check all key_set <- nonempty(uniq_list_of(term())),
value_set <- uniq_list_of(term(), length: Enum.count(key_set)),
check all key_set <- nonempty(uniq_list_of(atom(:alphanumeric))),
value_set <- uniq_list_of(integer(), length: Enum.count(key_set)),
Copy link
Owner

Choose a reason for hiding this comment

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

Actually, there is a deeper problem with this test:

iex> regular_map = %{x: 0}
iex> bimap = BiMap.new(regular_map)

iex> Map.put(regular_map, :a, 0)
#BiMap<[x: 0]>
iex> BiMap.put(bimap, :a, 0)
#BiMap<[a: 0]>

I'll push proper fix directly onto master

@mkaput
Copy link
Owner

mkaput commented Jun 17, 2019

Welp, good catch! Thanks!

@mkaput mkaput merged commit e0d013f into mkaput:master Jun 17, 2019
@mkaput
Copy link
Owner

mkaput commented Jun 17, 2019

@NullOranje I have just pushed a new version 1.0.1 with your patches :)

@NullOranje
Copy link
Contributor Author

Neat. Glad I could help make a nice module a little bit better.

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