# Why \*wouldn't\* one want to use @inferred in package tests?

**URL:** https://discourse.julialang.org/t/why-wouldnt-one-want-to-use-inferred-in-package-tests/2776
**Category:** Internals & Design
**Tags:** testing
**Created:** [March 20, 2017, 3:34pm UTC](https://discourse.julialang.org/t/why-wouldnt-one-want-to-use-inferred-in-package-tests/2776 "2017-03-20T15:34:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)
#### Post date: [March 20, 2017, 3:34pm UTC](https://discourse.julialang.org/t/why-wouldnt-one-want-to-use-inferred-in-package-tests/2776/1 "2017-03-20T15:34:43Z")

</div>

So, I [just found out](https://discourse.julialang.org/t/does-julia-syntax-do-enough-to-encourage-type-stability/2219/17) about [`Base.test.@inferred`](http://docs.julialang.org/en/stable/stdlib/test/#other-test-macros) and this looks like a nice way to ensure that functions are type-stable.

Is there any reason one shouldn’t use `@inferred` by default in all package tests? (That is, can/should I replace all `@test` statements with `@test @inferred`?)

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [March 20, 2017, 3:48pm UTC](https://discourse.julialang.org/t/why-wouldnt-one-want-to-use-inferred-in-package-tests/2776/2 "2017-03-20T15:48:02Z")

</div>

You donn’t use `@test @inferred`, just `@inferred`. If you want to make sure everything is inferred, you can, There are many things that aren’t inferrable though.

---

<div class="post-metadata">

### Author: ![Evizero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evizero/32/10118_2.png) [@Evizero](https://discourse.julialang.org/u/Evizero)
#### Post date: [March 20, 2017, 4:03pm UTC](https://discourse.julialang.org/t/why-wouldnt-one-want-to-use-inferred-in-package-tests/2776/3 "2017-03-20T16:03:15Z")

</div>

I do it in a lot of places and it usually looks something like this: [https://github.com/JuliaML/LossFunctions.jl/blob/master/test/tst\_api.jl#L30-L33](https://github.com/JuliaML/LossFunctions.jl/blob/master/test/tst_api.jl#L30-L33). Works like a charm. Note that it seems using parenthesis are important when doing `@test @inferred(...) == ...`.
