Skip to content
Open
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
8 changes: 8 additions & 0 deletions lib/patch/mock/code/transforms/remote.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ defmodule Patch.Mock.Code.Transforms.Remote do
end
end

defp expression({:bin, anno, body}, module, exports) do
{:bin, anno, expressions(body, module, exports)}
end

defp expression({:bin_element, anno, body, size, types}, module, exports) do
{:bin_element, anno, expression(body, module, exports), size, types}
end

defp expression({:block, anno, body}, module, exports) do
{:block, anno, expressions(body, module, exports)}
end
Expand Down
8 changes: 8 additions & 0 deletions test/support/user/patch/local_call.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ defmodule Patch.Test.Support.User.Patch.LocalCall do
{:original, public_function(a)}
end

def public_caller_string_interpolation(a) do
{:original, "#{inspect(public_function(a))}"}
end

def public_function(a) do
{:public, a}
end
Expand All @@ -19,6 +23,10 @@ defmodule Patch.Test.Support.User.Patch.LocalCall do
{:original, private_function(a)}
end

def private_caller_string_interpolation(a) do
{:original, "#{inspect(private_function(a))}"}
end

## Private

defp private_function(a) do
Expand Down
16 changes: 16 additions & 0 deletions test/user/patch/local_call_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ defmodule Patch.Test.User.Patch.LocalCallTest do
assert LocalCall.public_caller(:test_argument) == {:original, :patched}
end

test "can be patched in a string interpolation" do
assert LocalCall.public_caller_string_interpolation(:test_argument) == {:original, "{:public, :test_argument}"}

patch(LocalCall, :public_function, :patched)

assert LocalCall.public_caller_string_interpolation(:test_argument) == {:original, ":patched"}
end

test "can be assert_called" do
assert LocalCall.public_caller(:test_argument) == {:original, {:public, :test_argument}}

Expand Down Expand Up @@ -41,6 +49,14 @@ defmodule Patch.Test.User.Patch.LocalCallTest do
assert LocalCall.private_caller(:test_argument) == {:original, :patched}
end

test "can be patched in a string interpolation" do
assert LocalCall.private_caller_string_interpolation(:test_argument) == {:original, "{:private, :test_argument}"}

patch(LocalCall, :private_function, :patched)

assert LocalCall.private_caller_string_interpolation(:test_argument) == {:original, ":patched"}
end

test "can be assert_called" do
assert LocalCall.private_caller(:test_argument) == {:original, {:private, :test_argument}}

Expand Down