mruby-method/method.c (method_to_s): add location information.
Test updated too.
MODIFY
mrbgems/mruby-method/src/method.c
mrbgems/mruby-method/src/method.c
@@ -423,7 +423,14 @@ method_to_s(mrb_state *mrb, mrb_value self)
mrb_str_cat_lit(mrb, str, ")#");
mrb_str_concat(mrb, str, name);
}
- finish:
+ finish:;
+ mrb_value loc = method_source_location(mrb, self);
+ if (mrb_array_p(loc) && RARRAY_LEN(loc) == 2) {
+ mrb_str_cat_lit(mrb, str, " ");
+ mrb_str_concat(mrb, str, RARRAY_PTR(loc)[0]);
+ mrb_str_cat_lit(mrb, str, ":");
+ mrb_str_concat(mrb, str, RARRAY_PTR(loc)[1]);
+ }
mrb_str_cat_lit(mrb, str, ">");
return str;
}

MODIFY
mrbgems/mruby-method/test/method.rb
mrbgems/mruby-method/test/method.rb
@@ -230,14 +230,14 @@ assert 'to_s' do
o = Object.new
def o.foo; end
m = o.method(:foo)
- assert_equal("#<UnboundMethod: #{ class << o; self; end.inspect }#foo>", m.unbind.inspect)
+ assert_match("#<UnboundMethod: #{ class << o; self; end.inspect }#foo*>", m.unbind.inspect)
c = Class.new
c.class_eval { def foo; end; }
m = c.new.method(:foo)
- assert_equal("#<Method: #{ c.inspect }#foo>", m.inspect)
+ assert_match("#<Method: #{ c.inspect }#foo*>", m.inspect)
m = c.instance_method(:foo)
- assert_equal("#<UnboundMethod: #{ c.inspect }#foo>", m.inspect)
+ assert_match("#<UnboundMethod: #{ c.inspect }#foo*>", m.inspect)
end
assert 'owner' do

mruby-method/method.c (method_to_s): add location information.

Test updated too.