Skip to content

Commit

Permalink
Add more @test tests (#22609)
Browse files Browse the repository at this point in the history
* Add more passing `@test` tests

* Remove unused variable

* Add tests for `@test a ≈ b atol=ε` syntax
  • Loading branch information
omus authored and tkelman committed Jun 30, 2017
1 parent 32422d4 commit 71d7c16
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion base/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ end
# evaluate each term in the comparison individually so the results
# can be displayed nicely.
function get_test_result(ex)
orig_ex = Expr(:inert, ex)
# Normalize non-dot comparison operator calls to :comparison expressions
is_splat = x -> isa(x, Expr) && x.head == :...
if isa(ex, Expr) && ex.head == :call && length(ex.args) == 3 &&
Expand Down
11 changes: 11 additions & 0 deletions test/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@
@test true
@test 1 == 1
@test 1 != 2
@test ==(1, 1)
@test ==((1, 1)...)
@test 1 2 atol=1
@test strip("\t hi \n") == "hi"
@test strip("\t this should fail \n") != "hi"
@test isequal(1, 1)
@test isapprox(1, 1, atol=0.1)
@test isapprox(1, 1; atol=0.1)
@test isapprox(1, 1; [(:atol, 0)]...)

# @test keyword precedence: post-semicolon keyword, suffix keyword, pre-semicolon keyword
@test isapprox(1, 2, atol=0) atol=1
@test isapprox(1, 3, atol=0; atol=2) atol=1

# @test should only evaluate the arguments once
let g = Int[], f = (x) -> (push!(g, x); x)
Expand Down

0 comments on commit 71d7c16

Please sign in to comment.