range.c: fixed a begin-less ranges issue.

parent 80f6b14a
......@@ -409,7 +409,7 @@ mrb_range_beg_len(mrb_state *mrb, mrb_value range, mrb_int *begp, mrb_int *lenp,
if (!mrb_range_p(range)) return MRB_RANGE_TYPE_MISMATCH;
r = mrb_range_ptr(mrb, range);
beg = mrb_int(mrb, RANGE_BEG(r));
beg = mrb_nil_p(RANGE_BEG(r)) ? 0 : mrb_int(mrb, RANGE_BEG(r));
end = mrb_nil_p(RANGE_END(r)) ? -1 : mrb_int(mrb, RANGE_END(r));
excl = mrb_nil_p(RANGE_END(r)) ? 0 : RANGE_EXCL(r);
......
......@@ -58,6 +58,7 @@ assert('Array#[]', '15.2.12.5.4') do
assert_equal(["b", "c"], a[1,2])
assert_equal(["b", "c", "d"], a[1..-2])
assert_equal(["b", "c", "d", "e"], a[1..])
assert_equal(["a", "b", "c"], a[..2])
skip unless Object.const_defined?(:Float)
assert_equal("b", a[1.1])
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment