Commit e18a9c0a authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #788 from masamitsu-murase/modify_range_initialize

Modify range initialize to prevent segmentation fault.
parents 14c97e82 7941dfb4
...@@ -43,8 +43,8 @@ mrb_range_new(mrb_state *mrb, mrb_value beg, mrb_value end, int excl) ...@@ -43,8 +43,8 @@ mrb_range_new(mrb_state *mrb, mrb_value beg, mrb_value end, int excl)
struct RRange *r; struct RRange *r;
r = (struct RRange*)mrb_obj_alloc(mrb, MRB_TT_RANGE, RANGE_CLASS); r = (struct RRange*)mrb_obj_alloc(mrb, MRB_TT_RANGE, RANGE_CLASS);
r->edges = (struct mrb_range_edges *)mrb_malloc(mrb, sizeof(struct mrb_range_edges));
range_check(mrb, beg, end); range_check(mrb, beg, end);
r->edges = (struct mrb_range_edges *)mrb_malloc(mrb, sizeof(struct mrb_range_edges));
r->edges->beg = beg; r->edges->beg = beg;
r->edges->end = end; r->edges->end = end;
r->excl = excl; r->excl = excl;
......
...@@ -48,14 +48,13 @@ assert('Range#include', '15.2.14.4.8') do ...@@ -48,14 +48,13 @@ assert('Range#include', '15.2.14.4.8') do
a.include?(5) and not a.include?(20) a.include?(5) and not a.include?(20)
end end
# TODO SEGFAULT ATM assert('Range#initialize', '15.2.14.4.9') do
#assert('Range#initialize', '15.2.14.4.9') do a = Range.new(1, 10, true)
# a = Range.new(1, 10, true) b = Range.new(1, 10, false)
# b = Range.new(1, 10, false)
# a == (1...10) and a.exclude_end? and b == (1..10) and
# a == (1..10) and a.exclude_end? and b == (1..10) and not b.exclude_end?
# not b.exclude_end? end
#end
assert('Range#last', '15.2.14.4.10') do assert('Range#last', '15.2.14.4.10') do
(1..10).last == 10 (1..10).last == 10
......
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