Skip to content

Commit

Permalink
Range#intersects? never acts like an interval includes its start value
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Sobo committed Mar 14, 2008
1 parent 1f9b12a commit b6ffcfd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/treetop/ruby_extensions/range.rb
Expand Up @@ -3,7 +3,7 @@ def intersects?(other_range)
if exclude_end?
return false if last <= other_range.first || first >= other_range.last
else
return false if last < other_range.first || first > other_range.last
return false if last < other_range.first || (first >= other_range.last && first != last)
end
true
end
Expand Down
4 changes: 4 additions & 0 deletions spec/ruby_extensions/range_spec.rb
Expand Up @@ -16,6 +16,10 @@
(5..5).intersects?(1..5).should be_true
end

it "is false for an endpoint-inclusive interval whose #first is == to the argument's #last" do
(5..10).intersects?(1..5).should be_false
end

it "is false for an interval whose #first is >= than the argument's #last" do
(11...15).intersects?(5..10).should be_false
(10...15).intersects?(5..10).should be_false
Expand Down

0 comments on commit b6ffcfd

Please sign in to comment.