Using === instead if == in tests (and code)



Hello Julia Devs,

When dealing with packages which overload the behavior of == it is best to make sure tests use === when appropriate.

In DataArrays package, == can return NA which later caused an error in some tests. But the general pattern should be:

@test f(blah,blag,blag) == false

should become:

@test f(blah,blah,blah) === false

Perhaps this has applicability to other packages (especially those which rely on Nullable stuff - which sometimes feels like it generates more than a 100% of problems :wink: ).


In general I agree with you. Though in practice when the returned value is NA the test will throw an error anyway, so the problem will be caught. A stronger reason to prefer === is that x == false can (in theory) be true even if x is not the false singleton, so === is a stricter way to check the behavior of a function. More generally, === is useful since it allows checking the type (but of course it can only be used for immutables).

Pull requests to replace == with === where applicable would likely be welcome in most packages.