diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-17 10:46:21 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-05-17 10:46:21 +0000 |
commit | 989e07c0f2fa664a54e52a475c2fcc145f06539d (patch) | |
tree | 186a5a0e86de3ab43f0f641f41ba4c48e060f53b /spec/ruby | |
parent | d50ecb63ec02043865a4217af7e738f22ea6e8c7 (diff) | |
download | ruby-989e07c0f2fa664a54e52a475c2fcc145f06539d.tar.gz |
range.c: === by cover?
* range.c (range_eqq): switch `Range#===` to use `cover?` instead
of `include?`. [Feature #14575]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby')
-rw-r--r-- | spec/ruby/core/range/case_compare_spec.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/spec/ruby/core/range/case_compare_spec.rb b/spec/ruby/core/range/case_compare_spec.rb index e0da683649..9a33c5b73b 100644 --- a/spec/ruby/core/range/case_compare_spec.rb +++ b/spec/ruby/core/range/case_compare_spec.rb @@ -3,9 +3,18 @@ require_relative 'shared/cover_and_include' require_relative 'shared/cover' describe "Range#===" do - it "returns the result of calling #include? on self" do - range = 0...10 - range.should_receive(:include?).with(2).and_return(:true) - (range === 2).should == :true + ruby_version_is ""..."2.6" do + it "returns the result of calling #include? on self" do + range = 0...10 + range.should_receive(:include?).with(2).and_return(:true) + (range === 2).should == :true + end + end + + ruby_version_is "2.6" do + it "returns the result of calling #cover? on self" do + range = RangeSpecs::Custom.new(0)..RangeSpecs::Custom.new(10) + (range === RangeSpecs::Custom.new(2)).should == true + end end end |