From 93392c072a039d8fa4e47f689f206866e79248bb Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Sun, 27 Oct 2013 01:25:24 -0400 Subject: [PATCH] testing: use `@test` instead of `@assert` everywhere. --- test/arrayops.jl | 96 +++++++++++++------------- test/blas.jl | 96 +++++++++++++------------- test/ccall.jl | 4 +- test/iobuffer.jl | 168 ++++++++++++++++++++++----------------------- test/iterators.jl | 46 ++++++------- test/linalg.jl | 2 +- test/math.jl | 2 +- test/sparse.jl | 4 +- test/spawn.jl | 2 +- test/statistics.jl | 2 +- 10 files changed, 210 insertions(+), 212 deletions(-) diff --git a/test/arrayops.jl b/test/arrayops.jl index 490e4c37dea97..abf8939bd053c 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -265,14 +265,14 @@ end @test isequal(a,findn(z)) #argmin argmax -@assert indmax([10,12,9,11]) == 2 -@assert indmin([10,12,9,11]) == 3 -@assert findmin([NaN,3.2,1.8]) == (1.8,3) -@assert findmax([NaN,3.2,1.8]) == (3.2,2) -@assert findmin([NaN,3.2,1.8,NaN]) == (1.8,3) -@assert findmax([NaN,3.2,1.8,NaN]) == (3.2,2) -@assert findmin([3.2,1.8,NaN,2.0]) == (1.8,2) -@assert findmax([3.2,1.8,NaN,2.0]) == (3.2,1) +@test indmax([10,12,9,11]) == 2 +@test indmin([10,12,9,11]) == 3 +@test findmin([NaN,3.2,1.8]) == (1.8,3) +@test findmax([NaN,3.2,1.8]) == (3.2,2) +@test findmin([NaN,3.2,1.8,NaN]) == (1.8,3) +@test findmax([NaN,3.2,1.8,NaN]) == (3.2,2) +@test findmin([3.2,1.8,NaN,2.0]) == (1.8,2) +@test findmax([3.2,1.8,NaN,2.0]) == (3.2,1) ## permutedims ## @@ -357,13 +357,13 @@ end ## cumsum, cummin, cummax -@assert isequal(cummin([1, 2, 5, -1, 3, -2]), [1, 1, 1, -1, -1, -2]) -@assert isequal(cummax([1, 2, 5, -1, 3, -2]), [1, 2, 5, 5, 5, 5]) +@test isequal(cummin([1, 2, 5, -1, 3, -2]), [1, 1, 1, -1, -1, -2]) +@test isequal(cummax([1, 2, 5, -1, 3, -2]), [1, 2, 5, 5, 5, 5]) -@assert isequal(cummax([1 0; 0 1], 1), [1 0; 1 1]) -@assert isequal(cummax([1 0; 0 1], 2), [1 1; 0 1]) -@assert isequal(cummin([1 0; 0 1], 1), [1 0; 0 0]) -@assert isequal(cummin([1 0; 0 1], 2), [1 0; 0 0]) +@test isequal(cummax([1 0; 0 1], 1), [1 0; 1 1]) +@test isequal(cummax([1 0; 0 1], 2), [1 1; 0 1]) +@test isequal(cummin([1 0; 0 1], 1), [1 0; 0 0]) +@test isequal(cummin([1 0; 0 1], 2), [1 0; 0 0]) @test sum_kbn([1,1e100,1,-1e100]) == 2 @@ -379,53 +379,53 @@ begin @test isequal(cumsum(A,3),A3) R = repeat([1, 2], inner = [1], outer = [1]) - @assert R == [1, 2] + @test R == [1, 2] R = repeat([1, 2], inner = [2], outer = [1]) - @assert R == [1, 1, 2, 2] + @test R == [1, 1, 2, 2] R = repeat([1, 2], inner = [1], outer = [2]) - @assert R == [1, 2, 1, 2] + @test R == [1, 2, 1, 2] R = repeat([1, 2], inner = [2], outer = [2]) - @assert R == [1, 1, 2, 2, 1, 1, 2, 2] + @test R == [1, 1, 2, 2, 1, 1, 2, 2] R = repeat([1, 2], inner = [1, 1], outer = [1, 1]) - @assert R == [1, 2]'' + @test R == [1, 2]'' R = repeat([1, 2], inner = [2, 1], outer = [1, 1]) - @assert R == [1, 1, 2, 2]'' + @test R == [1, 1, 2, 2]'' R = repeat([1, 2], inner = [1, 2], outer = [1, 1]) - @assert R == [1 1; 2 2] + @test R == [1 1; 2 2] R = repeat([1, 2], inner = [1, 1], outer = [2, 1]) - @assert R == [1, 2, 1, 2]'' + @test R == [1, 2, 1, 2]'' R = repeat([1, 2], inner = [1, 1], outer = [1, 2]) - @assert R == [1 1; 2 2] + @test R == [1 1; 2 2] R = repeat([1 2; 3 4], inner = [1, 1], outer = [1, 1]) - @assert R == [1 2; + @test R == [1 2; 3 4] R = repeat([1 2; 3 4], inner = [1, 1], outer = [2, 1]) - @assert R == [1 2; + @test R == [1 2; 3 4; 1 2; 3 4] R = repeat([1 2; 3 4], inner = [1, 1], outer = [1, 2]) - @assert R == [1 2 1 2; + @test R == [1 2 1 2; 3 4 3 4] R = repeat([1 2; 3 4], inner = [1, 1], outer = [2, 2]) - @assert R == [1 2 1 2; + @test R == [1 2 1 2; 3 4 3 4; 1 2 1 2; 3 4 3 4] R = repeat([1 2; 3 4], inner = [2, 1], outer = [1, 1]) - @assert R == [1 2; + @test R == [1 2; 1 2; 3 4; 3 4] R = repeat([1 2; 3 4], inner = [2, 1], outer = [2, 1]) - @assert R == [1 2; + @test R == [1 2; 1 2; 3 4; 3 4; @@ -435,13 +435,13 @@ begin 3 4] R = repeat([1 2; 3 4], inner = [2, 1], outer = [1, 2]) - @assert R == [1 2 1 2; + @test R == [1 2 1 2; 1 2 1 2; 3 4 3 4; 3 4 3 4;] R = repeat([1 2; 3 4], inner = [2, 1], outer = [2, 2]) - @assert R == [1 2 1 2; + @test R == [1 2 1 2; 1 2 1 2; 3 4 3 4; 3 4 3 4; @@ -451,33 +451,33 @@ begin 3 4 3 4] R = repeat([1 2; 3 4], inner = [1, 2], outer = [1, 1]) - @assert R == [1 1 2 2; + @test R == [1 1 2 2; 3 3 4 4] R = repeat([1 2; 3 4], inner = [1, 2], outer = [2, 1]) - @assert R == [1 1 2 2; + @test R == [1 1 2 2; 3 3 4 4; 1 1 2 2; 3 3 4 4] R = repeat([1 2; 3 4], inner = [1, 2], outer = [1, 2]) - @assert R == [1 1 2 2 1 1 2 2; + @test R == [1 1 2 2 1 1 2 2; 3 3 4 4 3 3 4 4] R = repeat([1 2; 3 4], inner = [1, 2], outer = [2, 2]) - @assert R == [1 1 2 2 1 1 2 2; + @test R == [1 1 2 2 1 1 2 2; 3 3 4 4 3 3 4 4; 1 1 2 2 1 1 2 2; 3 3 4 4 3 3 4 4] R = repeat([1 2; 3 4], inner = [2, 2], outer = [1, 1]) - @assert R == [1 1 2 2; + @test R == [1 1 2 2; 1 1 2 2; 3 3 4 4; 3 3 4 4] R = repeat([1 2; 3 4], inner = [2, 2], outer = [2, 1]) - @assert R == [1 1 2 2; + @test R == [1 1 2 2; 1 1 2 2; 3 3 4 4; 3 3 4 4; @@ -487,13 +487,13 @@ begin 3 3 4 4] R = repeat([1 2; 3 4], inner = [2, 2], outer = [1, 2]) - @assert R == [1 1 2 2 1 1 2 2; + @test R == [1 1 2 2 1 1 2 2; 1 1 2 2 1 1 2 2; 3 3 4 4 3 3 4 4; 3 3 4 4 3 3 4 4] R = repeat([1 2; 3 4], inner = [2, 2], outer = [2, 2]) - @assert R == [1 1 2 2 1 1 2 2; + @test R == [1 1 2 2 1 1 2 2; 1 1 2 2 1 1 2 2; 3 3 4 4 3 3 4 4; 3 3 4 4 3 3 4 4; @@ -505,21 +505,21 @@ begin A = reshape([1:8], 2, 2, 2) R = repeat(A, inner = [1, 1, 2], outer = [1, 1, 1]) T = reshape([1:4, 1:4, 5:8, 5:8], 2, 2, 4) - @assert R == T + @test R == T A = Array(Int, 2, 2, 2) A[:, :, 1] = [1 2; 3 4] A[:, :, 2] = [5 6; 7 8] R = repeat(A, inner = [2, 2, 2], outer = [2, 2, 2]) - @assert R[1, 1, 1] == 1 - @assert R[2, 2, 2] == 1 - @assert R[3, 3, 3] == 8 - @assert R[4, 4, 4] == 8 - @assert R[5, 5, 5] == 1 - @assert R[6, 6, 6] == 1 - @assert R[7, 7, 7] == 8 - @assert R[8, 8, 8] == 8 + @test R[1, 1, 1] == 1 + @test R[2, 2, 2] == 1 + @test R[3, 3, 3] == 8 + @test R[4, 4, 4] == 8 + @test R[5, 5, 5] == 1 + @test R[6, 6, 6] == 1 + @test R[7, 7, 7] == 8 + @test R[8, 8, 8] == 8 A = rand(4,4) for s in {A[1:2:4, 1:2:4], sub(A, 1:2:4, 1:2:4)} diff --git a/test/blas.jl b/test/blas.jl index c41b2a4cfaf3f..7301179aa71bd 100644 --- a/test/blas.jl +++ b/test/blas.jl @@ -15,65 +15,65 @@ for elty in (Float32, Float64, Complex64, Complex128) v14 = convert(Vector{elty}, [1:4]) v41 = convert(Vector{elty}, [4:-1:1]) # gemv - @assert all(LinAlg.BLAS.gemv('N', I4, o4) .== o4) - @assert all(LinAlg.BLAS.gemv('T', I4, o4) .== o4) - @assert all(LinAlg.BLAS.gemv('N', el2, I4, o4) .== el2 * o4) - @assert all(LinAlg.BLAS.gemv('T', el2, I4, o4) .== el2 * o4) + @test all(LinAlg.BLAS.gemv('N', I4, o4) .== o4) + @test all(LinAlg.BLAS.gemv('T', I4, o4) .== o4) + @test all(LinAlg.BLAS.gemv('N', el2, I4, o4) .== el2 * o4) + @test all(LinAlg.BLAS.gemv('T', el2, I4, o4) .== el2 * o4) o4cp = copy(o4) - @assert all(LinAlg.BLAS.gemv!('N', one(elty), I4, o4, elm1, o4cp) .== z4) - @assert all(o4cp .== z4) + @test all(LinAlg.BLAS.gemv!('N', one(elty), I4, o4, elm1, o4cp) .== z4) + @test all(o4cp .== z4) o4cp[:] = o4 - @assert all(LinAlg.BLAS.gemv!('T', one(elty), I4, o4, elm1, o4cp) .== z4) - @assert all(o4cp .== z4) - @assert all(LinAlg.BLAS.gemv('N', U4, o4) .== v41) - @assert all(LinAlg.BLAS.gemv('N', U4, o4) .== v41) + @test all(LinAlg.BLAS.gemv!('T', one(elty), I4, o4, elm1, o4cp) .== z4) + @test all(o4cp .== z4) + @test all(LinAlg.BLAS.gemv('N', U4, o4) .== v41) + @test all(LinAlg.BLAS.gemv('N', U4, o4) .== v41) # gemm - @assert all(LinAlg.BLAS.gemm('N', 'N', I4, I4) .== I4) - @assert all(LinAlg.BLAS.gemm('N', 'T', I4, I4) .== I4) - @assert all(LinAlg.BLAS.gemm('T', 'N', I4, I4) .== I4) - @assert all(LinAlg.BLAS.gemm('T', 'T', I4, I4) .== I4) - @assert all(LinAlg.BLAS.gemm('N', 'N', el2, I4, I4) .== el2 * I4) - @assert all(LinAlg.BLAS.gemm('N', 'T', el2, I4, I4) .== el2 * I4) - @assert all(LinAlg.BLAS.gemm('T', 'N', el2, I4, I4) .== el2 * I4) - @assert all(LinAlg.BLAS.gemm('T', 'T', el2, I4, I4) .== el2 * I4) + @test all(LinAlg.BLAS.gemm('N', 'N', I4, I4) .== I4) + @test all(LinAlg.BLAS.gemm('N', 'T', I4, I4) .== I4) + @test all(LinAlg.BLAS.gemm('T', 'N', I4, I4) .== I4) + @test all(LinAlg.BLAS.gemm('T', 'T', I4, I4) .== I4) + @test all(LinAlg.BLAS.gemm('N', 'N', el2, I4, I4) .== el2 * I4) + @test all(LinAlg.BLAS.gemm('N', 'T', el2, I4, I4) .== el2 * I4) + @test all(LinAlg.BLAS.gemm('T', 'N', el2, I4, I4) .== el2 * I4) + @test all(LinAlg.BLAS.gemm('T', 'T', el2, I4, I4) .== el2 * I4) I4cp = copy(I4) - @assert all(LinAlg.BLAS.gemm!('N', 'N', one(elty), I4, I4, elm1, I4cp) .== Z4) - @assert all(I4cp .== Z4) + @test all(LinAlg.BLAS.gemm!('N', 'N', one(elty), I4, I4, elm1, I4cp) .== Z4) + @test all(I4cp .== Z4) I4cp[:] = I4 - @assert all(LinAlg.BLAS.gemm!('N', 'T', one(elty), I4, I4, elm1, I4cp) .== Z4) - @assert all(I4cp .== Z4) + @test all(LinAlg.BLAS.gemm!('N', 'T', one(elty), I4, I4, elm1, I4cp) .== Z4) + @test all(I4cp .== Z4) I4cp[:] = I4 - @assert all(LinAlg.BLAS.gemm!('T', 'N', one(elty), I4, I4, elm1, I4cp) .== Z4) - @assert all(I4cp .== Z4) + @test all(LinAlg.BLAS.gemm!('T', 'N', one(elty), I4, I4, elm1, I4cp) .== Z4) + @test all(I4cp .== Z4) I4cp[:] = I4 - @assert all(LinAlg.BLAS.gemm!('T', 'T', one(elty), I4, I4, elm1, I4cp) .== Z4) - @assert all(I4cp .== Z4) - @assert all(LinAlg.BLAS.gemm('N', 'N', I4, U4) .== U4) - @assert all(LinAlg.BLAS.gemm('N', 'T', I4, U4) .== L4) + @test all(LinAlg.BLAS.gemm!('T', 'T', one(elty), I4, I4, elm1, I4cp) .== Z4) + @test all(I4cp .== Z4) + @test all(LinAlg.BLAS.gemm('N', 'N', I4, U4) .== U4) + @test all(LinAlg.BLAS.gemm('N', 'T', I4, U4) .== L4) # gemm compared to (sy)(he)rk if iseltype(elm1,Complex) - @assert all(triu(LinAlg.BLAS.herk('U', 'N', U4)) .== triu(LinAlg.BLAS.gemm('N', 'T', U4, U4))) - @assert all(tril(LinAlg.BLAS.herk('L', 'N', U4)) .== tril(LinAlg.BLAS.gemm('N', 'T', U4, U4))) - @assert all(triu(LinAlg.BLAS.herk('U', 'N', L4)) .== triu(LinAlg.BLAS.gemm('N', 'T', L4, L4))) - @assert all(tril(LinAlg.BLAS.herk('L', 'N', L4)) .== tril(LinAlg.BLAS.gemm('N', 'T', L4, L4))) - @assert all(triu(LinAlg.BLAS.herk('U', 'C', U4)) .== triu(LinAlg.BLAS.gemm('T', 'N', U4, U4))) - @assert all(tril(LinAlg.BLAS.herk('L', 'C', U4)) .== tril(LinAlg.BLAS.gemm('T', 'N', U4, U4))) - @assert all(triu(LinAlg.BLAS.herk('U', 'C', L4)) .== triu(LinAlg.BLAS.gemm('T', 'N', L4, L4))) - @assert all(tril(LinAlg.BLAS.herk('L', 'C', L4)) .== tril(LinAlg.BLAS.gemm('T', 'N', L4, L4))) + @test all(triu(LinAlg.BLAS.herk('U', 'N', U4)) .== triu(LinAlg.BLAS.gemm('N', 'T', U4, U4))) + @test all(tril(LinAlg.BLAS.herk('L', 'N', U4)) .== tril(LinAlg.BLAS.gemm('N', 'T', U4, U4))) + @test all(triu(LinAlg.BLAS.herk('U', 'N', L4)) .== triu(LinAlg.BLAS.gemm('N', 'T', L4, L4))) + @test all(tril(LinAlg.BLAS.herk('L', 'N', L4)) .== tril(LinAlg.BLAS.gemm('N', 'T', L4, L4))) + @test all(triu(LinAlg.BLAS.herk('U', 'C', U4)) .== triu(LinAlg.BLAS.gemm('T', 'N', U4, U4))) + @test all(tril(LinAlg.BLAS.herk('L', 'C', U4)) .== tril(LinAlg.BLAS.gemm('T', 'N', U4, U4))) + @test all(triu(LinAlg.BLAS.herk('U', 'C', L4)) .== triu(LinAlg.BLAS.gemm('T', 'N', L4, L4))) + @test all(tril(LinAlg.BLAS.herk('L', 'C', L4)) .== tril(LinAlg.BLAS.gemm('T', 'N', L4, L4))) ans = similar(L4) - @assert all(tril(LinAlg.BLAS.herk('L','C', L4)) .== tril(LinAlg.BLAS.herk!('L', 'C', one(elty), L4, zero(elty), ans))) - @assert all(symmetrize!(ans, 'L') .== LinAlg.BLAS.gemm('T', 'N', L4, L4)) + @test all(tril(LinAlg.BLAS.herk('L','C', L4)) .== tril(LinAlg.BLAS.herk!('L', 'C', one(elty), L4, zero(elty), ans))) + @test all(symmetrize!(ans, 'L') .== LinAlg.BLAS.gemm('T', 'N', L4, L4)) else - @assert all(triu(LinAlg.BLAS.syrk('U', 'N', U4)) .== triu(LinAlg.BLAS.gemm('N', 'T', U4, U4))) - @assert all(tril(LinAlg.BLAS.syrk('L', 'N', U4)) .== tril(LinAlg.BLAS.gemm('N', 'T', U4, U4))) - @assert all(triu(LinAlg.BLAS.syrk('U', 'N', L4)) .== triu(LinAlg.BLAS.gemm('N', 'T', L4, L4))) - @assert all(tril(LinAlg.BLAS.syrk('L', 'N', L4)) .== tril(LinAlg.BLAS.gemm('N', 'T', L4, L4))) - @assert all(triu(LinAlg.BLAS.syrk('U', 'T', U4)) .== triu(LinAlg.BLAS.gemm('T', 'N', U4, U4))) - @assert all(tril(LinAlg.BLAS.syrk('L', 'T', U4)) .== tril(LinAlg.BLAS.gemm('T', 'N', U4, U4))) - @assert all(triu(LinAlg.BLAS.syrk('U', 'T', L4)) .== triu(LinAlg.BLAS.gemm('T', 'N', L4, L4))) - @assert all(tril(LinAlg.BLAS.syrk('L', 'T', L4)) .== tril(LinAlg.BLAS.gemm('T', 'N', L4, L4))) + @test all(triu(LinAlg.BLAS.syrk('U', 'N', U4)) .== triu(LinAlg.BLAS.gemm('N', 'T', U4, U4))) + @test all(tril(LinAlg.BLAS.syrk('L', 'N', U4)) .== tril(LinAlg.BLAS.gemm('N', 'T', U4, U4))) + @test all(triu(LinAlg.BLAS.syrk('U', 'N', L4)) .== triu(LinAlg.BLAS.gemm('N', 'T', L4, L4))) + @test all(tril(LinAlg.BLAS.syrk('L', 'N', L4)) .== tril(LinAlg.BLAS.gemm('N', 'T', L4, L4))) + @test all(triu(LinAlg.BLAS.syrk('U', 'T', U4)) .== triu(LinAlg.BLAS.gemm('T', 'N', U4, U4))) + @test all(tril(LinAlg.BLAS.syrk('L', 'T', U4)) .== tril(LinAlg.BLAS.gemm('T', 'N', U4, U4))) + @test all(triu(LinAlg.BLAS.syrk('U', 'T', L4)) .== triu(LinAlg.BLAS.gemm('T', 'N', L4, L4))) + @test all(tril(LinAlg.BLAS.syrk('L', 'T', L4)) .== tril(LinAlg.BLAS.gemm('T', 'N', L4, L4))) ans = similar(L4) - @assert all(tril(LinAlg.BLAS.syrk('L','T', L4)) .== tril(LinAlg.BLAS.syrk!('L', 'T', one(elty), L4, zero(elty), ans))) - @assert all(symmetrize!(ans, 'L') .== LinAlg.BLAS.gemm('T', 'N', L4, L4)) + @test all(tril(LinAlg.BLAS.syrk('L','T', L4)) .== tril(LinAlg.BLAS.syrk!('L', 'T', one(elty), L4, zero(elty), ans))) + @test all(symmetrize!(ans, 'L') .== LinAlg.BLAS.gemm('T', 'N', L4, L4)) end end diff --git a/test/ccall.jl b/test/ccall.jl index 49351a5a6b4aa..54c519cf7b716 100644 --- a/test/ccall.jl +++ b/test/ccall.jl @@ -1,3 +1,3 @@ ccall_test_func(x) = ccall((:testUcharX, "./libccalltest"), Int32, (Uint8,), x) -@assert ccall_test_func(3) == 1 -@assert ccall_test_func(259) == 1 +@test ccall_test_func(3) == 1 +@test ccall_test_func(259) == 1 diff --git a/test/iobuffer.jl b/test/iobuffer.jl index 01da0c4291a81..75785aabea091 100644 --- a/test/iobuffer.jl +++ b/test/iobuffer.jl @@ -1,118 +1,118 @@ ioslength(io::IOBuffer) = (io.seekable ? io.size : nb_available(io)) let io = IOBuffer() -@assert eof(io) -@assert try read(io,Uint8); false; catch e; isa(e,EOFError); end -@assert write(io,"abc") == 3 -@assert ioslength(io) == 3 -@assert position(io) == 3 -@assert eof(io) -@assert seek(io, 0) -@assert read(io, Uint8) == 'a' +@test eof(io) +@test try read(io,Uint8); false; catch e; isa(e,EOFError); end +@test write(io,"abc") == 3 +@test ioslength(io) == 3 +@test position(io) == 3 +@test eof(io) +@test seek(io, 0) +@test read(io, Uint8) == 'a' a = Array(Uint8, 2) -@assert read(io, a) == a -@assert a == ['b','c'] -@assert bytestring(io) == "abc" -@assert seek(io, 1) -@assert truncate(io, 2) -@assert position(io) == 1 -@assert !eof(io) -@assert seekend(io) -@assert position(io) == 2 -@assert truncate(io, 0) -@assert position(io) == 0 -@assert truncate(io, 10) -@assert position(io) == 0 -@assert all(io.data .== 0) -@assert write(io,Int16[1,2,3,4,5,6]) == 12 -@assert seek(io,2) -@assert truncate(io, 10) -@assert ioslength(io) == 10 +@test read(io, a) == a +@test a == ['b','c'] +@test bytestring(io) == "abc" +@test seek(io, 1) +@test truncate(io, 2) +@test position(io) == 1 +@test !eof(io) +@test seekend(io) +@test position(io) == 2 +@test truncate(io, 0) +@test position(io) == 0 +@test truncate(io, 10) +@test position(io) == 0 +@test all(io.data .== 0) +@test write(io,Int16[1,2,3,4,5,6]) == 12 +@test seek(io,2) +@test truncate(io, 10) +@test ioslength(io) == 10 io.readable = false -@assert try read(io,Uint8[0]); false; catch e; true; end -@assert truncate(io, 0) -@assert write(io,"boston\ncambridge\n") > 0 -@assert takebuf_string(io) == "boston\ncambridge\n" -@assert takebuf_string(io) == "" +@test try read(io,Uint8[0]); false; catch e; true; end +@test truncate(io, 0) +@test write(io,"boston\ncambridge\n") > 0 +@test takebuf_string(io) == "boston\ncambridge\n" +@test takebuf_string(io) == "" close(io) -@assert try write(io,Uint8[0]); false; catch e; true; end -@assert try seek(io,0); false; catch e; true; end -@assert eof(io) +@test try write(io,Uint8[0]); false; catch e; true; end +@test try seek(io,0); false; catch e; true; end +@test eof(io) end let io = IOBuffer("hamster\nguinea pig\nturtle") -@assert position(io) == 0 -@assert readline(io) == "hamster\n" -@assert readall(io) == "guinea pig\nturtle" -@assert try read(io,Uint8); false; catch e; isa(e,EOFError); end -@assert seek(io,0) -@assert read(io,Uint8) == 'h' -@assert try truncate(io,0); false; catch e; true; end -@assert try write(io,uint8(0)); false; catch e; true; end -@assert try write(io,Uint8[0]); false; catch e; true; end -@assert takebuf_string(io) == "hamster\nguinea pig\nturtle" -@assert takebuf_string(io) == "hamster\nguinea pig\nturtle" #should be unchanged +@test position(io) == 0 +@test readline(io) == "hamster\n" +@test readall(io) == "guinea pig\nturtle" +@test try read(io,Uint8); false; catch e; isa(e,EOFError); end +@test seek(io,0) +@test read(io,Uint8) == 'h' +@test try truncate(io,0); false; catch e; true; end +@test try write(io,uint8(0)); false; catch e; true; end +@test try write(io,Uint8[0]); false; catch e; true; end +@test takebuf_string(io) == "hamster\nguinea pig\nturtle" +@test takebuf_string(io) == "hamster\nguinea pig\nturtle" #should be unchanged close(io) end let io = PipeBuffer() -@assert try read(io,Uint8); false; catch e; isa(e,EOFError); end -@assert write(io,"pancakes\nwaffles\nblueberries\n") > 0 -@assert position(io) == 0 -@assert readline(io) == "pancakes\n" +@test try read(io,Uint8); false; catch e; isa(e,EOFError); end +@test write(io,"pancakes\nwaffles\nblueberries\n") > 0 +@test position(io) == 0 +@test readline(io) == "pancakes\n" Base.compact(io) -@assert readline(io) == "waffles\n" -@assert write(io,"whipped cream\n") > 0 -@assert readline(io) == "blueberries\n" -@assert try seek(io,0); false; catch e; true; end -@assert try truncate(io,0); false; catch e; true; end -@assert readline(io) == "whipped cream\n" +@test readline(io) == "waffles\n" +@test write(io,"whipped cream\n") > 0 +@test readline(io) == "blueberries\n" +@test try seek(io,0); false; catch e; true; end +@test try truncate(io,0); false; catch e; true; end +@test readline(io) == "whipped cream\n" Base.compact(io) -@assert position(io) == 0 -@assert ioslength(io) == 0 +@test position(io) == 0 +@test ioslength(io) == 0 Base.ensureroom(io,50) -@assert position(io) == 0 -@assert ioslength(io) == 0 -@assert length(io.data) == 50 +@test position(io) == 0 +@test ioslength(io) == 0 +@test length(io.data) == 50 Base.ensureroom(io,10) -@assert ioslength(io) == 0 -@assert length(io.data) == 50 +@test ioslength(io) == 0 +@test length(io.data) == 50 io.maxsize = 75 Base.ensureroom(io,100) -@assert ioslength(io) == 0 -@assert length(io.data) == 75 -@assert seekend(io) -@assert ioslength(io) == 0 -@assert position(io) == 0 +@test ioslength(io) == 0 +@test length(io.data) == 75 +@test seekend(io) +@test ioslength(io) == 0 +@test position(io) == 0 write(io,zeros(Uint8,200)) -@assert ioslength(io) == 75 -@assert length(io.data) == 75 +@test ioslength(io) == 75 +@test length(io.data) == 75 write(io,1) -@assert ioslength(io) == 75 -@assert length(io.data) == 75 +@test ioslength(io) == 75 +@test length(io.data) == 75 write(io,[1,2,3]) -@assert ioslength(io) == 75 -@assert length(io.data) == 75 +@test ioslength(io) == 75 +@test length(io.data) == 75 skip(io,1) -@assert write(io,uint8(104)) == 1 +@test write(io,uint8(104)) == 1 skip(io,3) -@assert write(io,"apples".data) == 3 +@test write(io,"apples".data) == 3 skip(io,71) -@assert write(io,'y') == 1 -@assert readall(io) == "happy" -@assert eof(io) +@test write(io,'y') == 1 +@test readall(io) == "happy" +@test eof(io) write(io,zeros(Uint8,73)) write(io,'a') write(io,'b') write(io,'c') write(io,'d') write(io,'e') -@assert ioslength(io) == 75 -@assert length(io.data) == 75 -@assert position(io) == 0 +@test ioslength(io) == 75 +@test length(io.data) == 75 +@test position(io) == 0 skip(io,72) -@assert takebuf_string(io) == "\0ab" -@assert takebuf_string(io) == "" +@test takebuf_string(io) == "\0ab" +@test takebuf_string(io) == "" # issues 4021 print(io, true) @@ -121,5 +121,3 @@ close(io) end @test isempty(readlines(IOBuffer())) - - diff --git a/test/iterators.jl b/test/iterators.jl index 280e3a05959fa..5b5b97dd676ea 100644 --- a/test/iterators.jl +++ b/test/iterators.jl @@ -11,37 +11,37 @@ function buildvec(f) return v end -macro assert_buildvec(ex...) +macro test_buildvec(ex...) :(@test buildvec($(ex[1])) == $(ex[2])) end -@assert_buildvec take(count(), 0) [] -@assert_buildvec take(count(), 5) [0:4] -@assert_buildvec take(count(1,3), 5) [1:3:13] -@assert_buildvec take(count(zeros(2,2)), 3) [i * eye(2) for i=0:2] +@test_buildvec take(count(), 0) [] +@test_buildvec take(count(), 5) [0:4] +@test_buildvec take(count(1,3), 5) [1:3:13] +@test_buildvec take(count(zeros(2,2)), 3) [i * eye(2) for i=0:2] -@assert_buildvec drop(1:5, 5) [] -@assert_buildvec drop(1:0, 0) [] -@assert_buildvec drop(1:5, 2) [3:5] +@test_buildvec drop(1:5, 5) [] +@test_buildvec drop(1:0, 0) [] +@test_buildvec drop(1:5, 2) [3:5] -@assert_buildvec cycle(1:0) [] -@assert_buildvec take(cycle(1:3), 8) [1:3,1:3,1:2] +@test_buildvec cycle(1:0) [] +@test_buildvec take(cycle(1:3), 8) [1:3,1:3,1:2] -@assert_buildvec repeat('a', 0) [] -@assert_buildvec repeat('a', 5) ['a' for i = 1:5] -@assert_buildvec take(repeat('a'), 5) ['a' for i = 1:5] +@test_buildvec repeat('a', 0) [] +@test_buildvec repeat('a', 5) ['a' for i = 1:5] +@test_buildvec take(repeat('a'), 5) ['a' for i = 1:5] -@assert_buildvec chain() [] -@assert_buildvec chain(1:0) [] -@assert_buildvec chain(4:8, 1:1) [4:8, 1:1] -@assert_buildvec chain(1:1, 4:8) [1:1, 4:8] -@assert_buildvec chain(1:3, 2:4, 1:0) [1:3, 2:4, 1:0] +@test_buildvec chain() [] +@test_buildvec chain(1:0) [] +@test_buildvec chain(4:8, 1:1) [4:8, 1:1] +@test_buildvec chain(1:1, 4:8) [1:1, 4:8] +@test_buildvec chain(1:3, 2:4, 1:0) [1:3, 2:4, 1:0] # matrix to vector m2v(m) = reshape(m, length(m)) -@assert_buildvec product() [] -@assert_buildvec product(1:2,1:0,1:1) [] -@assert_buildvec product(1:2,1:1) m2v([(i,j) for i=1:2, j=1:1]) -@assert_buildvec product(1:1,1:3) m2v([(i,j) for i=1:1, j=1:3]) -@assert_buildvec product(2:4,1:3,4:8) m2v([(i,j,k) for i=2:4, j=1:3, k=4:8]) +@test_buildvec product() [] +@test_buildvec product(1:2,1:0,1:1) [] +@test_buildvec product(1:2,1:1) m2v([(i,j) for i=1:2, j=1:1]) +@test_buildvec product(1:1,1:3) m2v([(i,j) for i=1:1, j=1:3]) +@test_buildvec product(2:4,1:3,4:8) m2v([(i,j,k) for i=2:4, j=1:3, k=4:8]) diff --git a/test/linalg.jl b/test/linalg.jl index d9d0fa9452834..6982254e56127 100644 --- a/test/linalg.jl +++ b/test/linalg.jl @@ -481,7 +481,7 @@ function test_approx_eq_vecs(a, b) n = size(a)[1] @test n==size(b)[1] elty = typeof(a[1]) - @assert elty==typeof(b[1]) + @test elty==typeof(b[1]) for i=1:n ev1, ev2 = a[:,i], b[:,i] deviation = min(abs(norm(ev1-ev2)),abs(norm(ev1+ev2))) diff --git a/test/math.jl b/test/math.jl index dc9619bfc3b98..22ae859e166d3 100644 --- a/test/math.jl +++ b/test/math.jl @@ -149,7 +149,7 @@ end # invdigamma for elty in (Float32, Float64) for val in [0.001, 0.01, 0.1, 1.0, 10.0] - @assert abs(invdigamma(digamma(convert(elty, val))) - convert(elty, val)) < 1e-8 + @test abs(invdigamma(digamma(convert(elty, val))) - convert(elty, val)) < 1e-8 end end diff --git a/test/sparse.jl b/test/sparse.jl index 73cce83f6b283..d68b2e0464590 100644 --- a/test/sparse.jl +++ b/test/sparse.jl @@ -87,5 +87,5 @@ rowval = int32([1,2,2,3,4,5,1,4,6,1,7,2,5,8,6,9,3,4,6,8,10,3,5,7,8,10,11]) colval = int32([1,2,3,3,4,5,6,6,6,7,7,8,8,8,9,9,10,10,10,10,10,11,11,11,11,11,11]) A = sparse(rowval, colval, ones(length(rowval))) P,post = Base.LinAlg.etree(A, true) -@assert P == int32([6,3,8,6,8,7,9,10,10,11,0]) -@assert post == int32([2,3,5,8,1,4,6,7,9,10,11]) +@test P == int32([6,3,8,6,8,7,9,10,10,11,0]) +@test post == int32([2,3,5,8,1,4,6,7,9,10,11]) diff --git a/test/spawn.jl b/test/spawn.jl index 16a426af365de..612fed302b38e 100644 --- a/test/spawn.jl +++ b/test/spawn.jl @@ -120,4 +120,4 @@ yield() # issue #4535 exename=joinpath(JULIA_HOME,(ccall(:jl_is_debugbuild,Cint,())==0?"julia-basic":"julia-debug-basic")) -@test readall(`$exename -e 'println(STDERR,"Hello World")'` .> `cat`) == "Hello World\n" \ No newline at end of file +@test readall(`$exename -e 'println(STDERR,"Hello World")'` .> `cat`) == "Hello World\n" diff --git a/test/statistics.jl b/test/statistics.jl index 89842df0cfa77..0dc05c52486ad 100644 --- a/test/statistics.jl +++ b/test/statistics.jl @@ -48,4 +48,4 @@ A = Complex128[exp(i*im) for i in 1:10^4] X = [1 0; 2 1; 3 0; 4 1; 5 10] y = [5, 3, 4, 2, 5] @test_approx_eq cov(X[:,1], X[:,2]) cov(X)[1,2] -@assert issym(cov(X)) +@test issym(cov(X))