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

Fixes LinkedHashMap::values() #1656 #1657

Merged
merged 1 commit into from
Nov 2, 2016

Conversation

ruslansennov
Copy link
Member

No description provided.

CharSeq actual = LinkedHashMap.<Integer, Character> empty().put(3, 'a').put(2, 'b').put(1, 'c').foldLeft(CharSeq.empty(), (s, t) -> s.append(t._2));
assertThat(actual).isEqualTo(CharSeq.of("abc"));
List<Character> actual = LinkedHashMap.<Integer, Character> empty().put(3, 'a').put(2, 'b').put(1, 'c').foldLeft(List.empty(), (s, t) -> s.append(t._2));
Assertions.assertThat(actual).isEqualTo(List.of('a', 'b', 'c'));
Copy link
Member Author

Choose a reason for hiding this comment

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

It was a big mistake to override assers* methods. They don't check ordering of iterables. It is sufficient for Map, but very dangerous for other cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes - also IntMap and IntMultimap hide methods overridden by Map/Multimap because IntMap only extends Traversable. It is not sufficient that they are backed by Map/Multimap. This is the reason we did not recognize a bug...

With 3.0.0 we will change the collection type hierarchy 'a bit'

  • Iterator will not be Iterable/Traversable anymore, instead it will be TraversableOnce
  • Map/Multimap will extend Traversable<V> instead of Traversable<K, V>

This will make IntMap/IntMultimap superfluous. But for the overridden assert* methods I have currently no better solution...

Copy link
Contributor

@danieldietrich danieldietrich Nov 2, 2016

Choose a reason for hiding this comment

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

Would it be simpler to have String instead of List?

String actual = LinkedHashMap....mkString();
Assertions.assertThat(actual).isEqualTo("(3, a)(2, b)(1, c)");

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the reason we did not recognize a bug...

No, this bug was not recognized because of there was not test for it :) But we could not notice the bug in fold(), if it were

@codecov-io
Copy link

Current coverage is 96.43% (diff: 100%)

Merging #1657 into master will not change coverage

@@             master      #1657   diff @@
==========================================
  Files            89         89          
  Lines         11123      11123          
  Methods           0          0          
  Messages          0          0          
  Branches       1893       1893          
==========================================
  Hits          10726      10726          
  Misses          243        243          
  Partials        154        154          

Powered by Codecov. Last update cfb4f0f...6466e98

@danieldietrich
Copy link
Contributor

Thank you! The test is ok as-is.

@danieldietrich danieldietrich merged commit 1cc8b83 into vavr-io:master Nov 2, 2016
@danieldietrich danieldietrich added this to the 2.0.5 milestone Nov 2, 2016
@ruslansennov ruslansennov deleted the hotfix1656 branch November 3, 2016 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants