diff options
Diffstat (limited to 'spec/ruby/core/range/shared')
| -rw-r--r-- | spec/ruby/core/range/shared/cover.rb | 2 | ||||
| -rw-r--r-- | spec/ruby/core/range/shared/cover_and_include.rb | 17 | ||||
| -rw-r--r-- | spec/ruby/core/range/shared/include.rb | 2 |
3 files changed, 16 insertions, 5 deletions
diff --git a/spec/ruby/core/range/shared/cover.rb b/spec/ruby/core/range/shared/cover.rb index 0b41a26455..eaefb45942 100644 --- a/spec/ruby/core/range/shared/cover.rb +++ b/spec/ruby/core/range/shared/cover.rb @@ -1,4 +1,4 @@ -# -*- encoding: binary -*- +# encoding: binary require_relative '../../../spec_helper' require_relative '../fixtures/classes' diff --git a/spec/ruby/core/range/shared/cover_and_include.rb b/spec/ruby/core/range/shared/cover_and_include.rb index f36a2cef8b..13fc5e1790 100644 --- a/spec/ruby/core/range/shared/cover_and_include.rb +++ b/spec/ruby/core/range/shared/cover_and_include.rb @@ -1,4 +1,4 @@ -# -*- encoding: binary -*- +# encoding: binary require_relative '../../../spec_helper' describe :range_cover_and_include, shared: true do @@ -20,8 +20,8 @@ describe :range_cover_and_include, shared: true do end it "returns true if other is an element of self for endless ranges" do - eval("(1..)").send(@method, 2.4).should == true - eval("(0.5...)").send(@method, 2.4).should == true + (1..).send(@method, 2.4).should == true + (0.5...).send(@method, 2.4).should == true end it "returns true if other is an element of self for beginless ranges" do @@ -29,6 +29,17 @@ describe :range_cover_and_include, shared: true do (...10.5).send(@method, 2.4).should == true end + it "returns false if values are not comparable" do + (1..10).send(@method, nil).should == false + (1...10).send(@method, nil).should == false + + (..10).send(@method, nil).should == false + (...10).send(@method, nil).should == false + + (1..).send(@method, nil).should == false + (1...).send(@method, nil).should == false + end + it "compares values using <=>" do rng = (1..5) m = mock("int") diff --git a/spec/ruby/core/range/shared/include.rb b/spec/ruby/core/range/shared/include.rb index c6c5c2becf..15a0e5fb9f 100644 --- a/spec/ruby/core/range/shared/include.rb +++ b/spec/ruby/core/range/shared/include.rb @@ -1,4 +1,4 @@ -# -*- encoding: binary -*- +# encoding: binary require_relative '../../../spec_helper' require_relative '../fixtures/classes' |
