Skip to content

Commit f713912

Browse files
committed
More careful seeding for unit tests, eliminate some unnecessary rand() calls
1 parent 122f955 commit f713912

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

test/abstractarray.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,14 @@
8686
end
8787

8888
@testset "full" begin
89-
m_a = randn(2,2)
89+
m_a = [0.831333 -1.91207; 0.200986 -0.69399]
9090
m_a = m_a*m_a.'
9191
m = SMatrix{2,2}(m_a)
9292
@test @inferred(full(Symmetric(m))) == m_a
9393
@test @inferred(full(Symmetric(m, :L))) == m_a
9494

95-
m_a = randn(2,2) + im*randn(2,2)
95+
m_a = [0.34911-2.08735im -0.438891-0.446692im;
96+
-0.666533-0.652323im 0.834871-2.10413im]
9697
m_a = m_a*m_a'
9798
m = SMatrix{2,2}(m_a)
9899
@test @inferred(full(Hermitian(m))) == m_a

test/det.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
@test det(eye(SMatrix{3,3})*im) == det(eye(3,3)*im)
77

88
@test det(@SMatrix [0 1 0; 1 0 0; 0 0 1]) == -1
9-
m = randn(Float64, 4,4)
9+
m = [0.570085 0.667147 0.264427 0.561446
10+
0.115197 0.141744 0.83314 0.0457302
11+
0.249238 0.841643 0.809544 0.908978
12+
0.72068 0.6155 0.210278 0.607331]
1013
@test det(SMatrix{4,4}(m)) det(m)
1114
#triu/tril
1215
@test det(@SMatrix [1 2; 0 3]) == 3

test/indexing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
end
146146

147147
@testset "Indexing with empty vectors" begin
148-
a = randn(2,2)
148+
a = [1.0 2.0; 3.0 4.0]
149149
@test a[SVector{0,Int}()] == SVector{0,Float64}(())
150150
@test a[SVector{0,Int}(),SVector{0,Int}()] == SMatrix{0,0,Float64,0}(())
151151
b = copy(a)

test/linalg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ using StaticArrays, Base.Test
155155

156156
@testset "trace" begin
157157
@test trace(@SMatrix [1.0 2.0; 3.0 4.0]) === 5.0
158-
@test_throws DimensionMismatch trace(@SMatrix rand(5,4))
158+
@test_throws DimensionMismatch trace(@SMatrix ones(5,4))
159159
end
160160

161161
@testset "size zero" begin

test/runtests.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ using StaticArrays
22
using Base.Test
33

44
# We generate a lot of matrices using rand(), but unit tests should be
5-
# deterministic, so seed the RNG here.
5+
# deterministic. Therefore seed the RNG here (and further down, to avoid test
6+
# file order dependence)
67
srand(42)
78

89
include("testutil.jl")
@@ -22,23 +23,23 @@ include("custom_types.jl")
2223
include("core.jl")
2324
include("abstractarray.jl")
2425
include("indexing.jl")
25-
include("mapreduce.jl")
26-
include("arraymath.jl")
26+
srand(42); include("mapreduce.jl")
27+
srand(42); include("arraymath.jl")
2728
include("broadcast.jl")
2829
include("linalg.jl")
29-
include("matrix_multiply.jl")
30-
include("triangular.jl")
30+
srand(42); include("matrix_multiply.jl")
31+
srand(42); include("triangular.jl")
3132
include("det.jl")
3233
include("inv.jl")
33-
include("solve.jl")
34-
include("eigen.jl")
34+
srand(42); include("solve.jl")
35+
srand(42); include("eigen.jl")
3536
include("expm.jl")
3637
include("sqrtm.jl")
3738
include("lyap.jl")
3839
include("lu.jl")
39-
include("qr.jl")
40-
include("chol.jl")
40+
srand(42); include("qr.jl")
41+
srand(42); include("chol.jl")
4142
include("deque.jl")
4243
include("io.jl")
4344
include("svd.jl")
44-
include("fixed_size_arrays.jl")
45+
srand(42); include("fixed_size_arrays.jl")

0 commit comments

Comments
 (0)