Fix condition of Range#include?

This commit is contained in:
ksss
2016-11-18 10:01:03 +09:00
parent 1685eff2a5
commit 4ef591c897
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -229,7 +229,7 @@ mrb_range_include(mrb_state *mrb, mrb_value range)
end = r->edges->end;
include_p = r_le(mrb, beg, val) && /* beg <= val */
((r->excl && r_gt(mrb, end, val)) || /* end > val */
(r_ge(mrb, end, val))); /* end >= val */
(!r->excl && r_ge(mrb, end, val))); /* end >= val */
return mrb_bool_value(include_p);
}
+4 -3
View File
@@ -43,10 +43,11 @@ assert('Range#first', '15.2.14.4.7') do
end
assert('Range#include?', '15.2.14.4.8') do
a = (1..10)
assert_true (1..10).include?(10)
assert_false (1..10).include?(11)
assert_true a.include?(5)
assert_false a.include?(20)
assert_true (1...10).include?(9)
assert_false (1...10).include?(10)
end
assert('Range#initialize', '15.2.14.4.9') do