From 71d7c168dc1412a030e1de5c3e1c98720d390b17 Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Fri, 30 Jun 2017 10:03:03 -0500 Subject: [PATCH] Add more `@test` tests (#22609) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add more passing `@test` tests * Remove unused variable * Add tests for `@test a ≈ b atol=ε` syntax --- base/test.jl | 1 - test/test.jl | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/base/test.jl b/base/test.jl index 0c2edfcf1f205..7b03312ae4e38 100644 --- a/base/test.jl +++ b/base/test.jl @@ -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 && diff --git a/test/test.jl b/test/test.jl index 4cfa37a719530..5a461509ba5d3 100644 --- a/test/test.jl +++ b/test/test.jl @@ -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)