-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Description
For some foo(x), mocking does not support the broadcasted expression:
julia> foo(x) = # do stuff
julia> function bar(X)
return @mock foo.(X)
end
ERROR: LoadError: expression is not a function call
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] @mock(::LineNumberNode, ::Module, ::Any) at /Users/glenn/.julia/packages/Mocking/U41JO/src/mock.jl:6
in expression starting at REPL[8]:2So one needs to call broadcast explicitly in the function call and in the patch:
function bar(X)
return @mock broadcast(foo, X)
end
# currently works
patch = @patch broadcast(foo, X) = # do stuff
Whereas it would be nice if the patch for unbroadcasted foo could also implicitly handle the broadcasted case so one then doesn't have to create two different patches:
function bar(X)
return @mock foo.(X)
end
# should work for @mock foo(x) and @mock foo.(X)
patch = @patch f(x) = # do stuff