Functions returning a literal are not seen by code coverage

If I have a function returning a literal

def is_test?(_), do: false

and I run mix test --cover I get 100% coverage even if the function is never called in any test.

If I change the function to

def is_test?(_), do: false or false

the coverage report show this as not covered.
Is this expected?
Thanks

At a guess, I would say that the compiler inlines the first call. If it was called, it would simply substitute “false” everywhere the function would be called.

2 Likes