Skip to content

[Core/hash] Add specs for Hash #<=, #>=, #<, #> for Ruby 2.3 #160

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
Nov 22, 2015
Merged

[Core/hash] Add specs for Hash #<=, #>=, #<, #> for Ruby 2.3 #160

merged 1 commit into from
Nov 22, 2015

Conversation

JuanitoFatas
Copy link
Member

@eregon eregon self-assigned this Nov 13, 2015
@eregon
Copy link
Member

eregon commented Nov 13, 2015

Thanks, this a good start!
I would like to test behavior when hashes are more unrelated to each other, for instance sth like
{a:1, b:2} < {c:3, d:4} and also document what is the behavior when values differ but the keys are the same.

@h2 = {a:1, b:2, c:3}
end

it "expects h1 <= h1 to return true" do
Copy link
Member

Choose a reason for hiding this comment

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

In general, it's better if the spec descriptions explain the behavior, for instance here it could be:
returns true when comparing against itself or ... against the same hash.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 sure, thanks.

@JuanitoFatas
Copy link
Member Author

@eregon Hello Benoit, I have updated specs, please take a look. Thank you.

@eregon
Copy link
Member

eregon commented Nov 22, 2015

Great work! 😀

I only have one concern left: we should specify what happens when the keys match but the values don't. Could you add an example per method about that? 😔

@JuanitoFatas
Copy link
Member Author

I notice one thing that in rubyspec test suite, we use lt, lte, gt, gte to describe <, <=, >, >=.

But in CRuby, those methods are defined as lt, le, gt, ge, do you think we should change rubyspec test suite file names and respective tests to be consistent?

eregon added a commit that referenced this pull request Nov 22, 2015
[Core/hash] Add specs for Hash #<=, #>=, #<, #> for Ruby 2.3
@eregon eregon merged commit d439436 into ruby:master Nov 22, 2015
@eregon
Copy link
Member

eregon commented Nov 22, 2015

Awesome, thank you for writing these specs! 🎉

Internal names of MRI are not considered, as they could be anything.
The RubySpec naming choice is described in https://github.com/ruby/mspec/blob/master/lib/mspec/utils/name_map.rb and it would be simpler to keep as-is unless there is a compelling reason to change (ge/gte is just personal preference I believe).

@JuanitoFatas JuanitoFatas deleted the ruby-23/core/hash-comparison branch November 22, 2015 16:17
@JuanitoFatas
Copy link
Member Author

The RubySpec naming choice is described in https://github.com/ruby/mspec/blob/master/lib/mspec/utils/name_map.rb

Thanks for the link!

🙇

@eregon eregon mentioned this pull request Dec 16, 2015
51 tasks
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