Skip to content

Commit

Permalink
Fix lost lineno
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Mar 25, 2017
1 parent 051e40c commit b1c5c3b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mrbgems/mruby-kernel-ext/test/kernel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand Down
1 change: 1 addition & 0 deletions src/backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ");
Expand Down

0 comments on commit b1c5c3b

Please sign in to comment.