# Jldoctest: expecting (incorrectly) an empty output

**URL:** <https://discourse.julialang.org/t/jldoctest-expecting-incorrectly-an-empty-output/66671>\
**Category:** General Usage\
**Tags:** documenter\
**Created:** [August 19, 2021, 1:08pm UTC](https://discourse.julialang.org/t/jldoctest-expecting-incorrectly-an-empty-output/66671 "2021-08-19T13:08:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [August 19, 2021, 1:08pm UTC](https://discourse.julialang.org/t/jldoctest-expecting-incorrectly-an-empty-output/66671/1 "2021-08-19T13:08:29Z")

</div>

I am getting the error below in a ` jldoctest`. The command, when copy/pasted, works perfectly fine. What can be wrong here?

````julia
#```jldoctest
│ julia> using CellListMap
│ 
│ julia> box = Box([ 10 0 0 
│ 0 10 5
│ 0 0 10 ], 1)
│ Box{TriclinicCell, 3, Float64, 9}
│ unit cell matrix: [10.0 0.0 0.0; 0.0 10.0 5.0; 0.0 0.0 10.0]
│ cutoff: 1.0
│ number of computing cells on each dimension: [12, 17, 12]
│ computing cell sizes: [1.0, 1.0, 1.0] (lcell: 1)
│ Total number of cells: 2448
│ 
#│ ```
│ 
│ Subexpression:
│ 
│ box = Box([ 10 0 0 
│ 0 10 5
│ 0 0 10 ], 1)
│ 
│ Evaluated output:
│ 
│ 
│ 
│ Expected output:
│ 
│ Box{TriclinicCell, 3, Float64, 9}
│ unit cell matrix: [10.0 0.0 0.0; 0.0 10.0 5.0; 0.0 0.0 10.0]
│ cutoff: 1.0
│ number of computing cells on each dimension: [12, 17, 12]
│ computing cell sizes: [1.0, 1.0, 1.0] (lcell: 1)
│ Total number of cells: 2448

````

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [August 19, 2021, 1:26pm UTC](https://discourse.julialang.org/t/jldoctest-expecting-incorrectly-an-empty-output/66671/2 "2021-08-19T13:26:51Z")

</div>

Very often the issue in such cases is that you forgot to properly pass around the `io` argument in your show method and instead print to `stdout`, not the specified `IO` object.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [August 19, 2021, 1:31pm UTC](https://discourse.julialang.org/t/jldoctest-expecting-incorrectly-an-empty-output/66671/3 "2021-08-19T13:31:45Z")

</div>

In this case it is this one:

```julia

function Base.show(io::IO,::MIME"text/plain",box::Box)
    println(typeof(box))
    println(" unit cell matrix: ", box.unit_cell.matrix) 
    println(" cutoff: ", box.cutoff)
    println(" number of computing cells on each dimension: ",box.nc)
    println(" computing cell sizes: ", box.cell_size, " (lcell: ",box.lcell,")")
    print(" Total number of cells: ", prod(box.nc))
end

```

Seems right, doesn’t it? At least that is what I understood from the help entry of `show` . (I am guessing that you’ll say that using print inside that is wrong 🙂 )

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [August 19, 2021, 1:33pm UTC](https://discourse.julialang.org/t/jldoctest-expecting-incorrectly-an-empty-output/66671/4 "2021-08-19T13:33:07Z")

</div>

No, you always need to pass `io` as the first argument to `print`/`println`.
