Fix lost lineno

This commit is contained in:
ksss
2017-03-25 15:37:31 +09:00
parent 051e40c049
commit b1c5c3b0a5
2 changed files with 3 additions and 0 deletions
+2
View File
@@ -6,6 +6,7 @@ end
assert('Kernel.caller, Kernel#caller') do
skip "backtrace isn't available" if caller(0).empty?
caller_lineno = __LINE__ + 3
c = Class.new do
def foo(*args)
caller(*args)
@@ -19,6 +20,7 @@ assert('Kernel.caller, Kernel#caller') do
bar(*args)
end
end
assert_equal "kernel.rb:#{caller_lineno}:in Object#foo", c.new.baz(0)[0][-26..-1]
assert_equal "#bar", c.new.baz[0][-4..-1]
assert_equal "#foo", c.new.baz(0)[0][-4..-1]
assert_equal "#bar", c.new.baz(1)[0][-4..-1]
+1
View File
@@ -81,6 +81,7 @@ get_backtrace_i(mrb_state *mrb, struct backtrace_location *loc, void *data)
str = mrb_str_new_cstr(mrb, loc->filename);
snprintf(buf, sizeof(buf), ":%d", loc->lineno);
mrb_str_cat_cstr(mrb, str, buf);
if (loc->method) {
mrb_str_cat_lit(mrb, str, ":in ");