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

**URL:** <https://discourse.julialang.org/t/using-instead-if-in-tests-and-code/3971>\
**Category:** Internals & Design\
**Tags:** proposal\
**Created:** [May 29, 2017, 10:52am UTC](https://discourse.julialang.org/t/using-instead-if-in-tests-and-code/3971 "2017-05-29T10:52:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [May 29, 2017, 10:52am UTC](https://discourse.julialang.org/t/using-instead-if-in-tests-and-code/3971/1 "2017-05-29T10:52:48Z")

</div>

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:

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

```

should become:

```julia
@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 😉 ).

---

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [May 29, 2017, 11:35am UTC](https://discourse.julialang.org/t/using-instead-if-in-tests-and-code/3971/2 "2017-05-29T11:35:03Z")

</div>

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.
