Skip to content

Commit

Permalink
Use more descriptive comments in test/broadcast.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
wsshin committed Aug 10, 2017
1 parent 1fb2024 commit 9cf3d2a
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,36 @@ end
end

@testset "2x2 StaticMatrix with 1x2 StaticMatrix" begin
# Issues #197, #242: broadcast between SArray and row-like SMatrix
m1 = @SMatrix [1 2; 3 4]
m2 = @SMatrix [1 4]
@test @inferred(broadcast(+, m1, m2)) === @SMatrix [2 6; 4 8] #197
@test @inferred(m1 .+ m2) === @SMatrix [2 6; 4 8] #197
@test @inferred(broadcast(+, m1, m2)) === @SMatrix [2 6; 4 8]
@test @inferred(m1 .+ m2) === @SMatrix [2 6; 4 8]
@test @inferred(m2 .+ m1) === @SMatrix [2 6; 4 8]
@test @inferred(m1 .* m2) === @SMatrix [1 8; 3 16] #197
@test @inferred(m1 .* m2) === @SMatrix [1 8; 3 16]
@test @inferred(m2 .* m1) === @SMatrix [1 8; 3 16]
@test @inferred(m1 ./ m2) === @SMatrix [1 1/2; 3 1] #197
@test @inferred(m1 ./ m2) === @SMatrix [1 1/2; 3 1]
@test @inferred(m2 ./ m1) === @SMatrix [1 2; 1/3 1]
@test @inferred(m1 .- m2) === @SMatrix [0 -2; 2 0] #197
@test @inferred(m1 .- m2) === @SMatrix [0 -2; 2 0]
@test @inferred(m2 .- m1) === @SMatrix [0 2; -2 0]
@test @inferred(m1 .^ m2) === @SMatrix [1 16; 3 256] #197
@test @inferred(m1 .^ m2) === @SMatrix [1 16; 3 256]
end

@testset "1x2 StaticMatrix with StaticVector" begin
# Issues #197, #242: broadcast between SVector and row-like SMatrix
m = @SMatrix [1 2]
v = SVector(1, 4)
@test @inferred(broadcast(+, m, v)) === @SMatrix [2 3; 5 6]
@test @inferred(m .+ v) === @SMatrix [2 3; 5 6]
@test @inferred(v .+ m) === @SMatrix [2 3; 5 6] #197
@test @inferred(v .+ m) === @SMatrix [2 3; 5 6]
@test @inferred(m .* v) === @SMatrix [1 2; 4 8]
@test @inferred(v .* m) === @SMatrix [1 2; 4 8] #197
@test @inferred(v .* m) === @SMatrix [1 2; 4 8]
@test @inferred(m ./ v) === @SMatrix [1 2; 1/4 1/2]
@test @inferred(v ./ m) === @SMatrix [1 1/2; 4 2] #197
@test @inferred(v ./ m) === @SMatrix [1 1/2; 4 2]
@test @inferred(m .- v) === @SMatrix [0 1; -3 -2]
@test @inferred(v .- m) === @SMatrix [0 -1; 3 2] #197
@test @inferred(v .- m) === @SMatrix [0 -1; 3 2]
@test @inferred(m .^ v) === @SMatrix [1 2; 1 16]
@test @inferred(v .^ m) === @SMatrix [1 1; 4 16] #197
@test @inferred(v .^ m) === @SMatrix [1 1; 4 16]
end

@testset "StaticVector with StaticVector" begin
Expand All @@ -87,10 +89,10 @@ end
@test @inferred(v2 .- v1) === SVector(0, 2)
@test @inferred(v1 .^ v2) === SVector(1, 16)
@test @inferred(v2 .^ v1) === SVector(1, 16)
# test case issue #199
# Issue #199: broadcast with empty SArray
@test @inferred(SVector(1) .+ SVector()) === SVector()
@test @inferred(SVector() .+ SVector(1)) === SVector()
# test case issue #200
# Issue #200: broadcast with RowVector
@test @inferred(v1 .+ v2') === @SMatrix [2 5; 3 6]
end

Expand Down

0 comments on commit 9cf3d2a

Please sign in to comment.