diff options
Diffstat (limited to 'spec/ruby/core/kernel/Float_spec.rb')
-rw-r--r-- | spec/ruby/core/kernel/Float_spec.rb | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/spec/ruby/core/kernel/Float_spec.rb b/spec/ruby/core/kernel/Float_spec.rb index af64fcbe86..0f83cb5824 100644 --- a/spec/ruby/core/kernel/Float_spec.rb +++ b/spec/ruby/core/kernel/Float_spec.rb @@ -41,7 +41,7 @@ describe :kernel_float, shared: true do end it "converts Strings to floats without calling #to_f" do - string = "10" + string = +"10" string.should_not_receive(:to_f) @object.send(:Float, string).should == 10.0 end @@ -306,27 +306,25 @@ describe :kernel_float, shared: true do -> { @object.send(:Float, c) }.should raise_error(RangeError) end - ruby_version_is "2.6" do - describe "when passed exception: false" do - describe "and valid input" do - it "returns a Float number" do - @object.send(:Float, 1, exception: false).should == 1.0 - @object.send(:Float, "1", exception: false).should == 1.0 - @object.send(:Float, "1.23", exception: false).should == 1.23 - end + describe "when passed exception: false" do + describe "and valid input" do + it "returns a Float number" do + @object.send(:Float, 1, exception: false).should == 1.0 + @object.send(:Float, "1", exception: false).should == 1.0 + @object.send(:Float, "1.23", exception: false).should == 1.23 end + end - describe "and invalid input" do - it "swallows an error" do - @object.send(:Float, "abc", exception: false).should == nil - @object.send(:Float, :sym, exception: false).should == nil - end + describe "and invalid input" do + it "swallows an error" do + @object.send(:Float, "abc", exception: false).should == nil + @object.send(:Float, :sym, exception: false).should == nil end + end - describe "and nil" do - it "swallows it" do - @object.send(:Float, nil, exception: false).should == nil - end + describe "and nil" do + it "swallows it" do + @object.send(:Float, nil, exception: false).should == nil end end end |