Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix condition of Range#include? #3255

Merged
merged 1 commit into from Nov 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/range.c
Expand Up @@ -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);
}
Expand Down
7 changes: 4 additions & 3 deletions test/t/range.rb
Expand Up @@ -43,10 +43,11 @@
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
Expand Down