<p dir="auto">If you <code class="notranslate">dev</code> the brand-new <a href="https://github.com/JuliaMath/CheckedArithmetic.jl">https://github.com/JuliaMath/CheckedArithmetic.jl</a> and then do <code class="notranslate">pkg&gt; test CheckedArithmetic</code>, all seems well. But then insert <code class="notranslate">error("oops")</code> <a href="https://github.com/JuliaMath/CheckedArithmetic.jl/blob/314697a1aba62165489b4a59c00bef8600ec8515/test/runtests.jl#L68">here</a>, and you'll find to your dismay that the tests still pass.</p>
<p dir="auto">If you comment out the "check" tests, then it fails as expected.</p>
<p dir="auto">EDIT: package has been fixed. It was due to a habit of writing <code class="notranslate">return val</code> at the end of a block, and mistakenly doing that in the <code class="notranslate">@check</code> macro definition.</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; using Test

julia&gt; @testset for i in 1:1
           @testset begin
               break
           end
       end
1-element Array{Any,1}:
 Test.DefaultTestSet(&quot;i = 1&quot;, Any[Test.DefaultTestSet(#= circular reference @-2 =#)], 0, false)

julia&gt; Test.get_testset_depth()  # != 0
1

julia&gt; @testset for i in 1:1  # same testset again
           @testset begin
               break
           end
       end
1-element Array{Any,1}:
 Test.DefaultTestSet(&quot;i = 1&quot;, Any[Test.DefaultTestSet(#= circular reference @-2 =#)], 0, false)

julia&gt; Test.get_testset_depth()  # != 0
2"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-k">using</span> Test

julia<span class="pl-k">&gt;</span> <span class="pl-c1">@testset</span> <span class="pl-k">for</span> i <span class="pl-k">in</span> <span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">1</span>
           <span class="pl-c1">@testset</span> <span class="pl-k">begin</span>
               <span class="pl-k">break</span>
           <span class="pl-k">end</span>
       <span class="pl-k">end</span>
<span class="pl-c1">1</span><span class="pl-k">-</span>element Array{Any,<span class="pl-c1">1</span>}<span class="pl-k">:</span>
 Test<span class="pl-k">.</span><span class="pl-c1">DefaultTestSet</span>(<span class="pl-s"><span class="pl-pds">"</span>i = 1<span class="pl-pds">"</span></span>, Any[Test<span class="pl-k">.</span><span class="pl-c1">DefaultTestSet</span>(<span class="pl-c"><span class="pl-c">#=</span> circular reference @-2 <span class="pl-c">=#</span></span>)], <span class="pl-c1">0</span>, <span class="pl-c1">false</span>)

julia<span class="pl-k">&gt;</span> Test<span class="pl-k">.</span><span class="pl-c1">get_testset_depth</span>()  <span class="pl-c"><span class="pl-c">#</span> != 0</span>
<span class="pl-c1">1</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">@testset</span> <span class="pl-k">for</span> i <span class="pl-k">in</span> <span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">1</span>  <span class="pl-c"><span class="pl-c">#</span> same testset again</span>
           <span class="pl-c1">@testset</span> <span class="pl-k">begin</span>
               <span class="pl-k">break</span>
           <span class="pl-k">end</span>
       <span class="pl-k">end</span>
<span class="pl-c1">1</span><span class="pl-k">-</span>element Array{Any,<span class="pl-c1">1</span>}<span class="pl-k">:</span>
 Test<span class="pl-k">.</span><span class="pl-c1">DefaultTestSet</span>(<span class="pl-s"><span class="pl-pds">"</span>i = 1<span class="pl-pds">"</span></span>, Any[Test<span class="pl-k">.</span><span class="pl-c1">DefaultTestSet</span>(<span class="pl-c"><span class="pl-c">#=</span> circular reference @-2 <span class="pl-c">=#</span></span>)], <span class="pl-c1">0</span>, <span class="pl-c1">false</span>)

julia<span class="pl-k">&gt;</span> Test<span class="pl-k">.</span><span class="pl-c1">get_testset_depth</span>()  <span class="pl-c"><span class="pl-c">#</span> != 0</span>
<span class="pl-c1">2</span></pre></div>
<p dir="auto">I think the code above should be an error.  Maybe <code class="notranslate">@testset</code> should be lowered into an "immediately invoked function expression"?</p>