Skip to content

Commit 02924c8

Browse files
committed
Add failing tests
1 parent 3ebba5c commit 02924c8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

stdlib/LinearAlgebra/test/structuredbroadcast.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,20 @@ end
289289
Dcopy = copy.(D)
290290
@test Dcopy isa T
291291
@test Dcopy == D
292+
Df = float.(D)
293+
@test Df isa T
294+
@test Df == D
295+
@test eltype(eltype(Df)) <: AbstractFloat
292296
@test (x -> (x,)).(D) == (x -> (x,)).(M)
297+
@test (x -> 1).(D) == ones(Int,size(D))
298+
@test_throws MethodError size.(D)
293299
end
294300
@testset "Diagonal" begin
295301
@testset "square" begin
296302
A = [1 3; 2 4]
297303
D = Diagonal([A, A])
298304
standardbroadcastingtests(D, Diagonal)
305+
@test sincos.(D) == sincos.(Matrix{eltype(D)}(D))
299306
M = [x for x in D]
300307
@test cos.(D) == cos.(M)
301308
end
@@ -309,6 +316,14 @@ end
309316
D = Diagonal([ones(Bool,3,4), ones(Bool,2,3)])
310317
standardbroadcastingtests(D, Diagonal)
311318
end
319+
320+
@testset "incompatible sizes" begin
321+
A = reshape(1:12, 4, 3)
322+
B = reshape(1:12, 3, 4)
323+
D1 = Diagonal(fill(A, 2))
324+
D2 = Diagonal(fill(B, 2))
325+
@test_throws DimensionMismatch D1 .+ D2
326+
end
312327
end
313328
@testset "Bidiagonal" begin
314329
A = [1 3; 2 4]

0 commit comments

Comments
 (0)