Skip to content

Commit f7cd6be

Browse files
Show only the \"Test Passed\" message when a test passes
This restores the behaviour of how `@test` shows a test pass in Julia v1.0 - v1.6, reverting the display changes that resulted when we began storing more info in the `Pass` type in JuliaLang#36879. Closes JuliaLang#43794.
1 parent f70a86a commit f7cd6be

File tree

2 files changed

+0
-28
lines changed

2 files changed

+0
-28
lines changed

stdlib/Test/docs/src/index.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,9 @@ If the condition is true, a `Pass` is returned:
4343
```jldoctest testfoo
4444
julia> @test foo("bar") == 9
4545
Test Passed
46-
Expression: foo("bar") == 9
47-
Evaluated: 9 == 9
4846
4947
julia> @test foo("fizz") >= 10
5048
Test Passed
51-
Expression: foo("fizz") >= 10
52-
Evaluated: 16 >= 10
5349
```
5450

5551
If the condition is false, then a `Fail` is returned and an exception is thrown:
@@ -88,7 +84,6 @@ to check that this occurs:
8884
```jldoctest testfoo
8985
julia> @test_throws MethodError foo(:cat)
9086
Test Passed
91-
Expression: foo(:cat)
9287
Thrown: MethodError
9388
```
9489

@@ -214,8 +209,6 @@ checks using either `@test a ≈ b` (where `≈`, typed via tab completion of `\
214209
```jldoctest
215210
julia> @test 1 ≈ 0.999999999
216211
Test Passed
217-
Expression: 1 ≈ 0.999999999
218-
Evaluated: 1 ≈ 0.999999999
219212
220213
julia> @test 1 ≈ 0.999999
221214
Test Failed at none:1
@@ -228,8 +221,6 @@ after the `≈` comparison:
228221
```jldoctest
229222
julia> @test 1 ≈ 0.999999 rtol=1e-5
230223
Test Passed
231-
Expression: ≈(1, 0.999999, rtol = 1.0e-5)
232-
Evaluated: ≈(1, 0.999999; rtol = 1.0e-5)
233224
```
234225
Note that this is not a specific feature of the `` but rather a general feature of the `@test` macro: `@test a <op> b key=val` is transformed by the macro into `@test op(a, b, key=val)`. It is, however, particularly useful for `` tests.
235226

stdlib/Test/src/Test.jl

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,13 @@ end
9494

9595
function Base.show(io::IO, t::Pass)
9696
printstyled(io, "Test Passed"; bold = true, color=:green)
97-
if !(t.orig_expr === nothing)
98-
print(io, "\n Expression: ", t.orig_expr)
99-
end
10097
if t.test_type === :test_throws
10198
# The correct type of exception was thrown
10299
if t.message_only
103100
print(io, "\n Message: ", t.value)
104101
else
105102
print(io, "\n Thrown: ", typeof(t.value))
106103
end
107-
elseif t.test_type === :test && t.data !== nothing
108-
# The test was an expression, so display the term-by-term
109-
# evaluated version as well
110-
print(io, "\n Evaluated: ", t.data)
111104
end
112105
end
113106

@@ -389,12 +382,9 @@ If executed outside a `@testset`, throw an exception instead of returning `Fail`
389382
```jldoctest
390383
julia> @test true
391384
Test Passed
392-
Expression: true
393385
394386
julia> @test [1, 2] + [2, 1] == [3, 3]
395387
Test Passed
396-
Expression: [1, 2] + [2, 1] == [3, 3]
397-
Evaluated: [3, 3] == [3, 3]
398388
```
399389
400390
The `@test f(args...) key=val...` form is equivalent to writing
@@ -404,8 +394,6 @@ is a call using infix syntax such as approximate comparisons:
404394
```jldoctest
405395
julia> @test π ≈ 3.14 atol=0.01
406396
Test Passed
407-
Expression: ≈(π, 3.14, atol = 0.01)
408-
Evaluated: ≈(π, 3.14; atol = 0.01)
409397
```
410398
411399
This is equivalent to the uglier test `@test ≈(π, 3.14, atol=0.01)`.
@@ -434,17 +422,13 @@ Test Broken
434422
435423
julia> @test 2 + 2 ≈ 5 atol=1 broken=false
436424
Test Passed
437-
Expression: ≈(2 + 2, 5, atol = 1)
438-
Evaluated: ≈(4, 5; atol = 1)
439425
440426
julia> @test 2 + 2 == 5 skip=true
441427
Test Broken
442428
Skipped: 2 + 2 == 5
443429
444430
julia> @test 2 + 2 == 4 skip=false
445431
Test Passed
446-
Expression: 2 + 2 == 4
447-
Evaluated: 4 == 4
448432
```
449433
450434
!!! compat "Julia 1.7"
@@ -699,17 +683,14 @@ Note that `@test_throws` does not support a trailing keyword form.
699683
```jldoctest
700684
julia> @test_throws BoundsError [1, 2, 3][4]
701685
Test Passed
702-
Expression: ([1, 2, 3])[4]
703686
Thrown: BoundsError
704687
705688
julia> @test_throws DimensionMismatch [1, 2, 3] + [1, 2]
706689
Test Passed
707-
Expression: [1, 2, 3] + [1, 2]
708690
Thrown: DimensionMismatch
709691
710692
julia> @test_throws "Try sqrt(Complex" sqrt(-1)
711693
Test Passed
712-
Expression: sqrt(-1)
713694
Message: "DomainError with -1.0:\\nsqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x))."
714695
```
715696

0 commit comments

Comments
 (0)