diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-27 20:21:25 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-27 20:21:25 +0000 |
commit | 37ef87c12b6c496001d0f199e46b4ecbfac5d394 (patch) | |
tree | 063c277e6343b299f6d47200e5b38f3af7975301 /spec/ruby/core/kernel | |
parent | ecf03376ec25fbd1ced6c0d1de110c6761e959fd (diff) | |
download | ruby-37ef87c12b6c496001d0f199e46b4ecbfac5d394.tar.gz |
Update to ruby/spec@cbe855c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/kernel')
-rw-r--r-- | spec/ruby/core/kernel/Float_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/kernel/Integer_spec.rb | 31 |
2 files changed, 22 insertions, 11 deletions
diff --git a/spec/ruby/core/kernel/Float_spec.rb b/spec/ruby/core/kernel/Float_spec.rb index ee20190094..824c54eac0 100644 --- a/spec/ruby/core/kernel/Float_spec.rb +++ b/spec/ruby/core/kernel/Float_spec.rb @@ -6,7 +6,7 @@ describe :kernel_float, shared: true do float = 1.12 float2 = @object.send(:Float, float) float2.should == float - float2.object_id.should == float.object_id + float2.should equal float end it "returns a Float for Fixnums" do diff --git a/spec/ruby/core/kernel/Integer_spec.rb b/spec/ruby/core/kernel/Integer_spec.rb index 979283eb23..d2e989af9f 100644 --- a/spec/ruby/core/kernel/Integer_spec.rb +++ b/spec/ruby/core/kernel/Integer_spec.rb @@ -10,18 +10,29 @@ describe :kernel_integer, shared: true do Integer(100).should == 100 end - it "raises a TypeError when to_int returns not-an-Integer object and to_i returns nil" do - obj = mock("object") - obj.should_receive(:to_int).and_return("1") - obj.should_receive(:to_i).and_return(nil) - lambda { Integer(obj) }.should raise_error(TypeError) + ruby_version_is ""..."2.6" do + it "uncritically return the value of to_int even if it is not an Integer" do + obj = mock("object") + obj.should_receive(:to_int).and_return("1") + obj.should_not_receive(:to_i) + Integer(obj).should == "1" + end end - it "return a result of to_i when to_int does not return an Integer" do - obj = mock("object") - obj.should_receive(:to_int).and_return("1") - obj.should_receive(:to_i).and_return(42) - Integer(obj).should == 42 + ruby_version_is "2.6" do + it "raises a TypeError when to_int returns not-an-Integer object and to_i returns nil" do + obj = mock("object") + obj.should_receive(:to_int).and_return("1") + obj.should_receive(:to_i).and_return(nil) + lambda { Integer(obj) }.should raise_error(TypeError) + end + + it "return a result of to_i when to_int does not return an Integer" do + obj = mock("object") + obj.should_receive(:to_int).and_return("1") + obj.should_receive(:to_i).and_return(42) + Integer(obj).should == 42 + end end it "raises a TypeError when passed nil" do |