summaryrefslogtreecommitdiff
path: root/test/ruby/test_range.rb
AgeCommit message (Collapse)Author
2019-05-23range.c (inspect_range): omit beginless "nil"Yusuke Endoh
except the special case `(nil..nil)`. ``` (1..).inspect #=> "1.." (..5).inspect #=> "..5" (nil..nil).inspect #=> "nil..nil" ``` [Bug #15745]
2019-05-01Add exception support in `Range#first`.manga_osyo
Closes: https://github.com/ruby/ruby/pull/2163
2019-04-08range.c: force hash values fixablenobu
* 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
2019-04-04range.c: support to make beginless arithmetic sequencesmrkn
* 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
2019-04-03range.c (r_cover_range_p): support beginless rangemame
`(..2).cover?(..1)` should return true. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-03Introduce beginless range [Feature#14799]mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-24numeric.c: Fix negative step with float componentsmrkn
* 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
2019-01-08range.c (range_last): disable optimization when each is redefinedmrkn
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
2019-01-05test/ruby/test_range.rb: add assertionsmrkn
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
2018-09-28range.c: Add Range#%mrkn
[Feature #14697] [ruby-core:86588] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-05range.c: Range#cover? accepts Range object. [Feature #14473]tarui
* 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
2018-08-06enumerator.c: Introduce Enumerator::ArithmeticSequencemrkn
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
2018-06-25test_range.rb: add tests to improve coveragewatson1978
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
2018-06-22test/ruby/test_range.rb: add a test for endless range's min with comparisonmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-22range.c: Range#last and #max raises a RangeError if it is endlessmame
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
2018-06-22range.c: Range#size now returns Float::INFINITY if it is endlessmame
Fixes [Bug #14699] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-22range.c: Range#to_a now raises RangeError if it is endlessmame
Fixes [Bug #14845] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-13Revert "range.c: prohibit `(1..nil)`"mame
This reverts commit a44c010764a16ae09aaed49d76eec055ca0057c8. Refs #14845. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-13range.c: prohibit `(1..nil)`mame
Now endless range can be created by either a literal `(1..)` or explicit range creation `Range.new(1, nil)`. [Bug #14845] This change is intended for "early failure"; for example, `(1..var).to_a` causes out of memory if `var` is inadvertently nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-17range.c: === by cover?nobu
* range.c (range_eqq): switch `Range#===` to use `cover?` instead of `include?`. [Feature #14575] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-28range.c: each on endless rangenobu
* range.c (range_each): endless range begins with string-like object should iterate from the converted result string, as well as `#each` on a string-end range or `#step` method on an endless range, i.e., `begin.succ` should not be called. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-20range.c: step in bignumnobu
* range.c (range_step): honor step in bignum addition. [Feature #12912] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-20range.c: fix fixnum loop conditionnobu
* range.c (range_step): FIXABLE + FIXABLE never overflow, but may not be FIXABLE. [Feature #12912] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-19range.c: Make Range#bsearch support endless rangesmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-19Make Range#min, max, include?, cover?, and === to support endless rangemame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-19Introduce endless range [Feature#12912]mame
Typical usages: ``` p ary[1..] # drop the first element; identical to ary[1..-1] (1..).each {|n|...} # iterate forever from 1; identical to 1.step{...} ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12Add FrozenError as a subclass of RuntimeErrorshyouhei
FrozenError will be used instead of RuntimeError for exceptions raised when there is an attempt to modify a frozen object. The reason for this change is to differentiate exceptions related to frozen objects from generic exceptions such as those generated by Kernel#raise without an exception class. From: Jeremy Evans <code@jeremyevans.net> Signed-off-by: Urabe Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-25range.c: use rb_check_funcallnobu
* range.c (rb_range_values): use rb_check_funcall instead of calling rb_respond_to then rb_funcall, and allow `begin` and `end` to be private as well as other internal conversions. [ruby-core:83541] [Bug #14048] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-25range.c: check if exclude_end? is definednobu
* range.c (rb_range_values): should raise TypeError if necessary method is not defined, not NoMethodError, when trying to tell if the object is a Range and extract info. [ruby-core:83541] [Bug #14048] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-25no longer rescue exceptions of #<=> when initializing a Rangeeregon
* range.c (range_init): no longer hide the user exception with a ArgumentError, just let the user exception go through. * test/ruby/test_range.rb (test_new): add tests. [Feature #7688] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-21Removed mathn.rb from stdlib. It's deprecated from Ruby 2.2.hsbt
[Feature #10169][[ruby-core:64553]] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-11range.c: check loadingnobu
* range.c (range_loader): check loading values if the data came from an initialized range object. [ruby-core:78067] [Bug #12915] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-10range.c: check if range modifiablenobu
* range.c (range_modify): frozen object cannot be modified. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-30test_range.rb: all assertionsnobu
* test/ruby/test_range.rb (test_range_bsearch_for_floats): test all assertions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-21hash method valuesnobu
* test/ruby/test_{complex,range,rational,struct}.rb (test_hash): hash values should be an Integer, not only a Fixnum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-17Optimize enum_sum for a range from int to intmrkn
* enum.c (enum_sum): Optimize for a range from int to int. * test/ruby/test_enum.rb (test_range_sum): Move from test_range.rb, and add assertions for some conditions. * test/ruby/test_enum.rb (test_hash_sum): Move from test_hash.rb. * test/ruby/test_hash.rb, test/ruby/test_range.rb: Remove test_sum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-17Implement Enumerable#summrkn
* enum.c (enum_sum): Implement Enumerable#sum. * test/ruby/test_enum.rb (test_sum): Test sum for Enumerable. * test/ruby/test_hash.rb (test_sum): Test sum for Hash. * test/ruby/test_range.rb (test_sum): Test sum for Range. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-17Use Integer instead of Fixnum and Bignum.akr
* object.c, numeric.c, enum.c, ext/-test-/bignum/mul.c, lib/rexml/quickpath.rb, lib/rexml/text.rb, lib/rexml/xpath_parser.rb, lib/rubygems/specification.rb, lib/uri/generic.rb, bootstraptest/test_eval.rb, basictest/test.rb, test/-ext-/bignum/test_big2str.rb, test/-ext-/bignum/test_div.rb, test/-ext-/bignum/test_mul.rb, test/-ext-/bignum/test_str2big.rb, test/csv/test_data_converters.rb, test/date/test_date.rb, test/json/test_json_generate.rb, test/minitest/test_minitest_mock.rb, test/openssl/test_cipher.rb, test/rexml/test_jaxen.rb, test/ruby/test_array.rb, test/ruby/test_basicinstructions.rb, test/ruby/test_bignum.rb, test/ruby/test_case.rb, test/ruby/test_class.rb, test/ruby/test_complex.rb, test/ruby/test_enum.rb, test/ruby/test_eval.rb, test/ruby/test_iseq.rb, test/ruby/test_literal.rb, test/ruby/test_math.rb, test/ruby/test_module.rb, test/ruby/test_numeric.rb, test/ruby/test_range.rb, test/ruby/test_rational.rb, test/ruby/test_refinement.rb, test/ruby/test_rubyvm.rb, test/ruby/test_struct.rb, test/ruby/test_variable.rb, test/rubygems/test_gem_specification.rb, test/thread/test_queue.rb: Use Integer instead of Fixnum and Bignum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-23* range.c (range_eqq): revert r11113 because rb_call_super() isshugo
called in range_include() and thus r11113 doesn't work when the receiver Range object consists of non linear objects such as Date objects. [ruby-core:72908] [Bug #12003] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-03range.c: infected by the receivernobu
* range.c (range_to_s): should be infected by the receiver. str2 infects by appending. [ruby-core:71811] [Bug #11767] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-22* test/ruby/test_range.rb: Add test case for Range#end withhsbt
exclude_end true case. [fix GH-968] Pach by @yui-knk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21* test/ruby/test_range.rb: Add test for Range#hashhsbt
[fix GH-969] Patch by @yui-knk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51318 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17test_range.rb: add Range#new testnobu
* test/ruby/test_range.rb (test_first_last): Add test for `Range.new`. [Fix GH-971] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17test_range.rb: add Range#last assertionsnobu
* test/ruby/test_range.rb (test_first_last): Add assertions to test of `Range#last` with exclude_end true case. [Fix GH-970] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51276 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-03range.c: covered for linear objectsnobu
* range.c (linear_object_p, range_include): test if covered for linear objects. [ruby-core:69052] [Bug #11113] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-13range.c: class name encodingnobu
* range.c (range_bsearch): preserve encoding of class name in an exception message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13* test/lib/envutil.rb: Moved from test/ruby/.akr
* test/lib/find_executable.rb: Ditto. * test/lib/memory_status.rb: Ditto. * test/lib/test/unit.rb: require envutil. * test/: Don't require envutil in test files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-13* enum.c (nmin_run): max(n) and max_by(n) returns an array inakr
descending order. [ruby-core:65452] Suggested by David Grayson. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-26* test/ruby/test_range.rb: added workaround for VERBOSE message.hsbt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e