-
Notifications
You must be signed in to change notification settings - Fork 184
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
Ruby 2.7: Beginless ranges fully supported #2211
Conversation
I'll let @norswap review the rest. |
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.
Looks good. Great work on all these new specs 👍
unless beg_compare | ||
return false if range.begin # not beginless | ||
beg_compare = -1 | ||
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.
Same as cover_range?
, hard to follow because of the existing code.
Proposal (completely untested):
def self.cover?(range, value)
# Check lower bound.
if !Primitive.nil?(range.begin)
# MRI uses <=> to compare, so must we.
cmp = (range.begin <=> value)
return false if Compare.compare_int(cmp) > 0
end
# Check upper bound.
if !Primitive.nil(range.end)
value = value + (range.exclude_end? 1 : 0)
cmp = (value <=> range.end)
return false if Comparable.compare_int(cmp) > 0
end
true
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.
Also much more beautiful, thanks!
Also, r_less
is no longer being used, so I commented it out; not sure if it should be removed altogether.
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.
Yes, let's remove range_less
if it's unused :)
(we can always use the git history to restore it if it's useful in the future)
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.
Seems good to go for me, unless there are more changes that need to go in?
I'm done and ready to merge. Thank you for the great suggestions! |
Great PR to finish a tricky set of specs! |
There has some CI failures, I'm not sure why GitHub Actions didn't run on the last changes.
Lint:
|
Thanks for letting me know, I think it's fixed now! The non-running tests could have something to do with the fact the CHANGELOG is conflicting? In the future I'll wait until after the reviews to write it. |
That seems likely, I didn't think about it. A workaround would be to rebase the PR, but we'll try first if this now passes the internal CI. |
PullRequest: truffleruby/2313
Finishing up from #2155
In this PR, added support for:
Range#{cover?, include?, ===}.
String#{byteslice, slice, slice!} and Symbol#slice
Kernel#{caller, caller_locations} and Thread#backtrace_locations
Shopify#1