-
-
Notifications
You must be signed in to change notification settings - Fork 388
Write Enumerable#uniq specs #447
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
Conversation
core/enumerable/uniq_spec.rb
Outdated
end | ||
end | ||
|
||
it 'returns an array that contains only unique result of the given block' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unique elements
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Updated as it in 2fa99e3 🙇
core/enumerable/uniq_spec.rb
Outdated
|
||
it 'returns an array that contains only unique result of the given block' do | ||
@enum.uniq { |_, label| label.downcase }.should == [0, 2] | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be interesting to also test it without a block :)
BTW, [1, 2, 1].to_enum
is an easy way to make an Enumerator with sample values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result is a bit weird for handling multiple yield arguments, I don't have confident that is an expected behavior... 🤔
But it is out of scope of this basic spec, so simplified as 2fa99e3, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be interesting to report it to https://bugs.ruby-lang.org/ and ask what is the intended behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be fine to keep that example, we can always change it later if Enumerable#uniq
is changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've PRed at ruby/ruby#1658
report it to https://bugs.ruby-lang.org/ and ask what is the intended behavior
🙆♂️ So I'll issue in https://bugs.ruby-lang.org/ too 🏃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://bugs.ruby-lang.org/issues/13669 ☑️
It would be fine to keep that example, we can always change it later if Enumerable#uniq is changed.
👍 The example has been kept as 5bc06e0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kachick Awesome, thanks a lot!
This shows how valuable it is to write new specs 😃
Thanks for your review and merging! 🙏 |
No description provided.