mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
range.c: fixed a begin-less ranges issue.
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user