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

Align Range#cover? extension behavior with plain Ruby behavior for "backwards" ranges #38837

Merged
merged 1 commit into from Mar 30, 2020
Merged

Align Range#cover? extension behavior with plain Ruby behavior for "backwards" ranges #38837

merged 1 commit into from Mar 30, 2020

Conversation

groeneman
Copy link
Contributor

Summary

Previously:

In irb:

irb(main):002:0> RUBY_VERSION
=> "2.6.5"
irb(main):004:0> (1..10).cover?(6..3)
=> false

In rails (HEAD) console

irb(main):001:0> RUBY_VERSION
=> "2.6.5"
irb(main):003:0> (1..10).cover?(6..3)
=> true

Updated the Range#cover? core extension so that (1..10).cover?(5..3) now returns false, as it does in plain Ruby.

Also updated #include? and #=== behavior to match, though in this case there is no plain-Ruby equivalent.

activesupport/CHANGELOG.md Outdated Show resolved Hide resolved
activesupport/test/core_ext/range_ext_test.rb Outdated Show resolved Hide resolved
@groeneman
Copy link
Contributor Author

@eugeneius thanks for the feedback. PR updated with revisions.

@eugeneius
Copy link
Member

This looks good, could you squash down to a single commit?

…rds ranges.

`(1..10).cover?(5..3)` now returns `false`, as it does in plain Ruby. Previously this returned `true`.

Also update `#include?` and `#===` behavior to match.
@groeneman
Copy link
Contributor Author

@eugeneius done

@eugeneius eugeneius merged commit 1239b22 into rails:master Mar 30, 2020
@eugeneius
Copy link
Member

Thank you!

@groeneman groeneman deleted the fix-activesupport-range-cover branch March 30, 2020 21:24
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.

None yet

2 participants