Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 3 commits into from
Jun 20, 2017
Merged

Write Enumerable#uniq specs #447

merged 3 commits into from
Jun 20, 2017

Conversation

kachick
Copy link
Member

@kachick kachick commented Jun 20, 2017

No description provided.

end
end

it 'returns an array that contains only unique result of the given block' do
Copy link
Member

Choose a reason for hiding this comment

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

unique elements maybe?

Copy link
Member Author

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 🙇


it 'returns an array that contains only unique result of the given block' do
@enum.uniq { |_, label| label.downcase }.should == [0, 2]
end
Copy link
Member

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.

Copy link
Member Author

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!

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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 🏃

Copy link
Member Author

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.

Copy link
Member

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 😃

@eregon eregon merged commit 39d313d into ruby:master Jun 20, 2017
@kachick
Copy link
Member Author

kachick commented Jun 21, 2017

Thanks for your review and merging! 🙏

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