Skip to content

Commit

Permalink
testing: use @test instead of @assert everywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Oct 27, 2013
1 parent 9d8e715 commit 93392c0
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 212 deletions.
96 changes: 48 additions & 48 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##

Expand Down Expand Up @@ -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

Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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)}
Expand Down
96 changes: 48 additions & 48 deletions test/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions test/ccall.jl
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 93392c0

Please sign in to comment.