Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/power_assert/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ def initialize(base_caller_length)
if (tp.event == :c_return && diff == 1 || tp.event == :return && diff <= 2) and Thread.current == @target_thread
idx = -(base_caller_length + 1)
if @parser.path == locs[idx].path and @parser.lineno == locs[idx].lineno
ret = tp.return_value
ret = tp.self if method_id == :initialize
val = PowerAssert.configuration.lazy_inspection ?
tp.return_value :
InspectedValue.new(SafeInspectable.new(tp.return_value).inspect)
ret :
InspectedValue.new(SafeInspectable.new(ret).inspect)
@return_values << Value[method_id.to_s, val, locs[idx].lineno, nil]
end
end
Expand Down
6 changes: 5 additions & 1 deletion lib/power_assert/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ def extract_idents(sexp)
end
when :@ident, :@const, :@op
_, method_name, (_, column) = sexp
[Ident[:method, method_name, column]]
m = [Ident[:method, method_name, column]]
if method_name == "new"
m << Ident[:method, "initialize", column]
end
m
else
[]
end
Expand Down
Loading