Age | Commit message (Collapse) | Author |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Caused by 04a92a6764bf678919cf4b68a27496a39d6b886a. This treats
unbounded ranges of arbitrary objects the same as how unbounded
string ranges are treated:
(..x) === y # (y <=> x) <= 0
(...x) === y # (y <=> x) < 0
(x..) === y # (x <=> y) <= 0
Fixes [Bug #19864]
|
|
Empty ranges do not overlap with any range.
Regarding benchmarks, PR#8242 is significantly faster in some cases,
but one of these two cases is a wrong result.
| |ActiveSupport| PR#8242|built-ruby|
|:--------------------------|------------:|-------:|---------:|
|(2..3).overlap?(1..1) | 7.761M| 15.053M| 32.368M|
| | -| 1.94x| 4.17x|
|(2..3).overlap?(2..4) | 25.720M| 55.070M| 21.981M|
| | 1.17x| 2.51x| -|
|(2..3).overlap?(4..5) | 7.616M| 15.048M| 21.730M|
| | -| 1.98x| 2.85x|
|(2..3).overlap?(2..1) | 25.585M| 56.545M| 32.786M|
| | -| 2.21x| 1.28x|
|(2..3).overlap?(0..1) | 7.554M| 14.755M| 32.545M|
| | -| 1.95x| 4.31x|
|(2..3).overlap?(...1) | 6.681M| 5.843M| 32.255M|
| | 1.14x| -| 5.52x|
|(2...3).overlap?(..2) | 6.676M| 5.817M| 21.572M|
| | 1.15x| -| 3.71x|
|(2...3).overlap?(3...) | 7.392M| 14.755M| 31.805M|
| | -| 2.00x| 4.30x|
|(2..3).overlap?('a'..'d') | 3.675M| 3.482M| 17.009M|
| | 1.06x| -| 4.89x|
|
|
Add a method that returns true if two range overlap, otherwise false.
```
(0..10).overlap?(5..15) #=> true
(0..10).overlap?(20..30) #=> false
```
|
|
When we extract bigdecimal as bundled gems, this test will be failed
with `make test-all`.
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/7574
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/7277
|
|
Beginless ranges previously raised TypeError for this case,
except for string ranges, which had unexpected behavior:
('a'..'z').include?('ww') # false
(..'z').include?('ww') # previously true, now TypeError
Use of include? with endless ranges could previously result
in an infinite loop.
This splits off a range_string_cover_internal function from
range_include_internal.
Fixes [Bug #18580]
Notes:
Merged: https://github.com/ruby/ruby/pull/6261
|
|
Fixes [Bug #18983]
Notes:
Merged: https://github.com/ruby/ruby/pull/6604
|
|
Previously `(2..).cover?("2"..)` was false, but
`(..2).cover?(.."2")` was true. This changes it so both are false,
treating beginless ranges the same as endless ranges in regards to
type checks.
This also adds documentation to #cover? to describe behavior with
beginless and endless ranges, testing each documentation example,
which is how this bug was found.
Fixes [Bug #18155]
Notes:
Merged: https://github.com/ruby/ruby/pull/5831
|
|
Previously, include? would return true for the end of the range,
when it should return false because the range is exclusive.
Research and Analysis by Victor Shepelev.
Fixes [Bug #18577]
Notes:
Merged: https://github.com/ruby/ruby/pull/5541
|
|
* numeric.c: prohibit zero step in Numeric#step
* range.c: prohibit zero step in Range#step
* Fix ruby-spec
[Feature #15573]
Notes:
Merged: https://github.com/ruby/ruby/pull/3689
Merged-By: mrkn <mrkn@ruby-lang.org>
|
|
Matz want to try to freeze all Range objects.
[Feature #15504]
Notes:
Merged: https://github.com/ruby/ruby/pull/3583
|
|
end" (tests)
Reverted in e080a4cdee
Notes:
Merged: https://github.com/ruby/ruby/pull/3501
|
|
non-integer end"
This reverts commit 8900a25581822759daca528d46a75e0b743fc22e.
Notes:
Merged: https://github.com/ruby/ruby/pull/3500
|
|
This reverts commit 05bf811c2839628aaef3d565daedb28be80d47ef.
Notes:
Merged: https://github.com/ruby/ruby/pull/3500
|
|
Popular Ruby libraries such as Rails and Rubocop relying on the
previous behavior, even though it is technically a bug. The
correct behavior is probably raising RangeError, since that is what
an endless range raises.
Related to [Bug #17017]
|
|
* Fix Range#max for beginless Integer ranges
* Update test/ruby/test_range.rb
* Fix formatting
https://github.com/ruby/ruby/pull/3328
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Notes:
Merged-By: nobu <nobu@ruby-lang.org>
|
|
Previously, for inclusive ranges, the max would show up as the
end of the range, even though the end was not an integer and would
not be the maximum value. For exclusive ranges, max/minmax would
previously raise a TypeError, even though it is possible to get the
correct maximum.
This change to max/minmax also uncovered a similar error in cover?,
which calls max in certain cases, so adjust the code there so that
cover? still works as expected.
Fixes [Bug #17017]
Notes:
Merged: https://github.com/ruby/ruby/pull/3306
Merged-By: jeremyevans <code@jeremyevans.net>
|
|
The implementation of Range#minmax added in d5c60214c45 causes the
following incorrect behaviour:
('a'...'c').minmax => ["a", ["a", "b"]]
instead of
('a'...'c').minmax => ["a", "b"]
This is because the C implementation of Range#minmax (range_minmax)
directly delegates to the C implementation of Range#min (range_min) and
Range#max (range_max), without changing the execution context.
Range#max's C implementation (range_max), when given a non-numeric
exclusive range, delegates to super, which is meant to call
Enumerable#max. However, because range_max is called directly by
range_minmax, super calls Enumerable#minmax instead, causing the
incorrect nesting.
Perhaps it is possible to change the execution context in an optimized
manner, but the simplest solution seems to be to just explicitly
delegate from Range#minmax to Range#min and Range#max.
Notes:
Merged: https://github.com/ruby/ruby/pull/3285
|
|
[Bug #16450]
|
|
As matz requested in [Bug #16366].
|
|
This removes the related tests, and puts the related specs behind
version guards. This affects all code in lib, including some
libraries that may want to support older versions of Ruby.
Notes:
Merged: https://github.com/ruby/ruby/pull/2476
|
|
|
|
Previously, Range#=== treated string ranges that were not endless or
beginless the same as include?, instead of the same as cover?.
I think this was an oversight in 989e07c0f2fa664a54e52a475c2fcc145f06539d,
as the commit message did not indicate this behavior was desired.
This also makes some previously dead code no longer dead. Previously,
the conditionals were doing this:
if (RB_TYPE_P(beg, T_STRING)
if (NIL_P(beg)) # can never be true
This restructures it so at the NIL_P(beg) check, beg could possibly
be nil (beginless ranges).
Fixes [Bug #15449]
|
|
Range#minmax was previous not implemented, so calling #minmax on
range was actually calling Enumerable#minmax. This is a simple
implementation of #minmax by just calling range_min and range_max.
Fixes [Bug #15867]
Fixes [Bug #15807]
|
|
except the special case `(nil..nil)`.
```
(1..).inspect #=> "1.."
(..5).inspect #=> "..5"
(nil..nil).inspect #=> "nil..nil"
```
[Bug #15745]
|
|
Closes: https://github.com/ruby/ruby/pull/2163
|
|
* range.c (range_hash): force hash values fixable on LLP64
environment. [ruby-core:92194] [Bug #15757]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_step): fix the guard condition so that a beginless
range can be turned into a beginless arithmetic sequence.
* test/ruby/test_range.rb (test_step): add assertions for the above
change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
`(..2).cover?(..1)` should return true.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* numeric.c (ruby_float_step): fix negative step with float components.
* test/ruby/test_numeric.c (test_step_bug15537): add tests.
* test/ruby/test_range.c (test_step_bug15537): add tests.
[Bug #15537] [ruby-core:91101]
From: shuujii (Shuji KOBAYASHI) <shuujii@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
Do not use the optimized version of Range#last when Range#each is
redefined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
Add assertions of Range#first and Range#last to examine the type
conversion of the arguments and the negative value check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
[Feature #14697] [ruby-core:86588]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_cover): add code for range argument.
If the argument is a Range, check it is or is not
covered by the reciver. If it can be treated as a
sequence, this method treats it that way.
* test/ruby/test_range.rb (class TestRange): add tests
for this feature.
This patch is written by Owen Stephens. thank you!
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
This commit introduces new core class Enumerator::ArithmeticSequence.
Enumerator::ArithmeticSequence is a subclass of Enumerator, and
represents a number generator of an arithmetic sequence.
After this commit, Numeric#step and Range#step without blocks
returned an ArithmeticSequence object instead of an Enumerator.
This class introduces the following incompatibilities:
- You can create a zero-step ArithmeticSequence,
and its size is not ArgumentError, but Infinity.
- You can create a negative-step ArithmeticSequence from a range.
[ruby-core:82816] [Feature #13904]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
This patch will improve the result of line coverage from 91.3% to 95.0%.
[Fix GH-1899]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
Also, Range#min raises an error if it is endless and a comparison method
is specified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
Fixes [Bug #14699]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|