Skip to content

Commit 9ae642a

Browse files
author
KDr2
committed
Fix test cases
1 parent 6963197 commit 9ae642a

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/taskcopy.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function Base.copy(t::Task)
8484
end
8585

8686
struct CTaskException
87+
etype
8788
msg::String
8889
backtrace::Vector{Union{Ptr{Nothing}, Base.InterpreterIP}}
8990
end
@@ -191,7 +192,12 @@ consume(p::Task, values...) = begin
191192
return p.result
192193
end
193194
if p.exception != nothing
194-
throw(CTaskException(p.exception.msg, p.backtrace))
195+
msg = if :msg in fieldnames(typeof(p.exception))
196+
p.exception.msg
197+
else
198+
string(typeof(p.exception))
199+
end
200+
throw(CTaskException(typeof(p.exception), msg, p.backtrace))
195201
end
196202
end
197203
wait()

test/brokentask.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ r = @testset "Broken Functions Tests" begin
1717
try
1818
consume(t)
1919
catch ex
20-
@test isa(ex, ErrorException)
20+
@test ex.etype == ErrorException
2121
end
2222
@test isa(t.exception, ErrorException)
2323
end
@@ -37,7 +37,7 @@ r = @testset "Broken Functions Tests" begin
3737
try
3838
consume(t)
3939
catch ex
40-
@test isa(ex, BoundsError)
40+
@test ex.etype == BoundsError
4141
end
4242
@test isa(t.exception, BoundsError)
4343
end
@@ -58,7 +58,7 @@ r = @testset "Broken Functions Tests" begin
5858
try
5959
consume(t)
6060
catch ex
61-
@test isa(ex, BoundsError)
61+
@test ex.etype == BoundsError
6262
end
6363
@test isa(t.exception, BoundsError)
6464
end
@@ -80,7 +80,7 @@ r = @testset "Broken Functions Tests" begin
8080
try
8181
consume(t_copy)
8282
catch ex
83-
@test isa(ex, BoundsError)
83+
@test ex.etype == BoundsError
8484
end
8585
@test isa(t_copy.exception, BoundsError)
8686
end

test/clonetask.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ function g_break()
5656
end
5757

5858
t = CTask(g_break)
59-
@test_throws MethodError consume(t)
59+
@test_throws Libtask.CTaskException consume(t)

0 commit comments

Comments
 (0)