Permalink
Browse files

Fix lost lineno

  • Loading branch information...
ksss committed Mar 25, 2017
1 parent 051e40c commit b1c5c3b0a5f5409d61c24ae312abe4229cc7e276
Showing with 3 additions and 0 deletions.
  1. +2 −0 mrbgems/mruby-kernel-ext/test/kernel.rb
  2. +1 −0 src/backtrace.c
@@ -6,6 +6,7 @@
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 @@ def baz(*args)
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]
View
@@ -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 ");

0 comments on commit b1c5c3b

Please sign in to comment.