Skip to content

Commit

Permalink
Add tests for CompositeException (#54174)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt authored Apr 22, 2024
1 parent d6dda7c commit 94b9a9a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/error.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,24 @@ end
using .Issue54029
@test Base.infer_return_type(raise54029, (Any,)) === Union{}
@test Base.infer_return_type(xs->raise54029(xs...), (Vector{Any},)) === Union{}

@testset "CompositeException" begin
ce = CompositeException()
@test isempty(ce)
@test length(ce) == 0
@test eltype(ce) == Any
str = sprint(showerror, ce)
@test str == "CompositeException()\n"
push!(ce, ErrorException("something sad has happened"))
@test !isempty(ce)
@test length(ce) == 1
pushfirst!(ce, ErrorException("something sad has happened even earlier"))
@test length(ce) == 2
# test iterate
for ex in ce
@test ex isa ErrorException
end
push!(ce, ErrorException("something sad has happened yet again"))
str = sprint(showerror, ce)
@test str == "something sad has happened even earlier\n\n...and 2 more exceptions.\n"
end

0 comments on commit 94b9a9a

Please sign in to comment.