diff options
Diffstat (limited to 'spec/ruby/library/bigdecimal/to_s_spec.rb')
-rw-r--r-- | spec/ruby/library/bigdecimal/to_s_spec.rb | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/spec/ruby/library/bigdecimal/to_s_spec.rb b/spec/ruby/library/bigdecimal/to_s_spec.rb index acc2e943f0..75741c5050 100644 --- a/spec/ruby/library/bigdecimal/to_s_spec.rb +++ b/spec/ruby/library/bigdecimal/to_s_spec.rb @@ -15,8 +15,16 @@ describe "BigDecimal#to_s" do @bigneg.to_s.kind_of?(String).should == true end - it "the default format looks like 0.xxxxEnn" do - @bigdec.to_s.should =~ /^0\.[0-9]*E[0-9]*$/i + ruby_version_is ''...'2.4' do + it "the default format looks like 0.xxxxEnn" do + @bigdec.to_s.should =~ /^0\.[0-9]*E[0-9]*$/ + end + end + + ruby_version_is '2.4' do + it "the default format looks like 0.xxxxenn" do + @bigdec.to_s.should =~ /^0\.[0-9]*e[0-9]*$/ + end end it "takes an optional argument" do @@ -63,10 +71,12 @@ describe "BigDecimal#to_s" do end it "can use conventional floating point notation" do - @bigdec.to_s("F").should == @bigdec_str - @bigneg.to_s("F").should == @bigneg_str - str2 = "+123.45678901 23456789" - BigDecimal('123.45678901234567890').to_s('+8F').should == str2 + %w[f F].each do |format_char| + @bigdec.to_s(format_char).should == @bigdec_str + @bigneg.to_s(format_char).should == @bigneg_str + str2 = "+123.45678901 23456789" + BigDecimal('123.45678901234567890').to_s("+8#{format_char}").should == str2 + end end end |