From e026368061c56bc925aff58910a4b02f18b78c70 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 21 Oct 2022 13:39:15 +0900 Subject: Range#size returns nil for (.."a") and (nil..) Fixes [Bug #18983] --- spec/ruby/core/range/size_spec.rb | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'spec/ruby/core') 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 -- cgit v1.2.3