summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-03 08:35:57 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-03 08:35:57 +0000
commitd4319541e870b3ec37ddb73d399dafcb39db35e7 (patch)
treec26843ab9f435c9de64822c904bdf4707a53a730 /range.c
parent95f7992b89efd35de6b28ac095c4d3477019c583 (diff)
range.c (r_cover_range_p): support beginless range
`(..2).cover?(..1)` should return true. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r--range.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/range.c b/range.c
index 6895511e59d..acf4a5cd742 100644
--- a/range.c
+++ b/range.c
@@ -1484,8 +1484,9 @@ r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val)
val_end = RANGE_END(val);
if (!NIL_P(end) && NIL_P(val_end)) return FALSE;
- if (!NIL_P(val_end) && r_less(val_beg, val_end) > -EXCL(val)) return FALSE;
- if (!r_cover_p(range, beg, end, val_beg)) return FALSE;
+ if (!NIL_P(beg) && NIL_P(val_beg)) return FALSE;
+ if (!NIL_P(val_beg) && !NIL_P(val_end) && r_less(val_beg, val_end) > -EXCL(val)) return FALSE;
+ if (!NIL_P(val_beg) && !r_cover_p(range, beg, end, val_beg)) return FALSE;
cmp_end = r_less(end, val_end);