summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2022-10-21 13:39:15 +0900
committerYusuke Endoh <mame@ruby-lang.org>2022-10-21 16:35:46 +0900
commite026368061c56bc925aff58910a4b02f18b78c70 (patch)
treed4934806d3d9fa62957121d2e7f8dfacc050439b /spec
parente72c5044cec4bb881300c3a4ade839d0882ec9db (diff)
Range#size returns nil for (.."a") and (nil..)
Fixes [Bug #18983]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6604
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/core/range/size_spec.rb27
1 files changed, 22 insertions, 5 deletions
diff --git a/spec/ruby/core/range/size_spec.rb b/spec/ruby/core/range/size_spec.rb
index 5462a1a5e1..9b625c9963 100644
--- a/spec/ruby/core/range/size_spec.rb
+++ b/spec/ruby/core/range/size_spec.rb
@@ -34,11 +34,28 @@ describe "Range#size" do
eval("([]...)").size.should == nil
end
- it 'returns Float::INFINITY for all beginless ranges' do
- (..1).size.should == Float::INFINITY
- (...0.5).size.should == Float::INFINITY
- (..nil).size.should == Float::INFINITY
- (...'o').size.should == Float::INFINITY
+ ruby_version_is ""..."3.2" do
+ it 'returns Float::INFINITY for all beginless ranges' do
+ (..1).size.should == Float::INFINITY
+ (...0.5).size.should == Float::INFINITY
+ (..nil).size.should == Float::INFINITY
+ (...'o').size.should == Float::INFINITY
+ end
+ end
+
+ ruby_version_is "3.2" do
+ it 'returns Float::INFINITY for all beginless ranges if the start is numeric' do
+ (..1).size.should == Float::INFINITY
+ (...0.5).size.should == Float::INFINITY
+ end
+
+ it 'returns nil for all beginless ranges if the start is numeric' do
+ (...'o').size.should == nil
+ end
+
+ it 'returns nil if the start and the end is both nil' do
+ (nil..nil).size.should == nil
+ end
end
it "returns nil if first and last are not Numeric" do