Is there a way to invoke a function
f1(::A) = nothing
with an argument that is not of the type A
?
So basically
invoke(f1, Tuple{A}, a)
where a
is not of the type A
.
As for the context: For advanced testing, I want to pass a mock object, whose behavior I specifically designed for this test, to a function that is supposed to take an argument of the non-mocked type.
For example, I want to test the function
f2(a::A) = do_something_with(a)
like this
mock_a = Val(:mock_a)
do_something_with(a::Val{:mock_a}) = predefined_behavior_for_this_test()
@test f2(a) == do_something_with(a)