mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
@@ -129,6 +129,9 @@ mrb_range_initialize(mrb_state *mrb, mrb_value range)
|
||||
exclusive = FALSE;
|
||||
}
|
||||
/* Ranges are immutable, so that they should be initialized only once. */
|
||||
if (mrb_range_ptr(range)->edges) {
|
||||
mrb_name_error(mrb, mrb_intern_lit(mrb, "initialize"), "`initialize' called twice");
|
||||
}
|
||||
range_init(mrb, range, beg, end, exclusive);
|
||||
return range;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,8 @@ assert('Range#initialize', '15.2.14.4.9') do
|
||||
assert_true a.exclude_end?
|
||||
assert_equal (1..10), b
|
||||
assert_false b.exclude_end?
|
||||
|
||||
assert_raise(NameError) { (0..1).send(:initialize, 1, 3) }
|
||||
end
|
||||
|
||||
assert('Range#last', '15.2.14.4.10') do
|
||||
|
||||
Reference in New Issue
Block a user