Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix error show #36

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/test.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# Wrap objects so we don't get confused iterating
# inside the objects themselves during tests.
struct TestObjectWrapper{O}
objects::O
end

struct InterfaceError <: Exception
t::Type
name::Symbol
Expand All @@ -16,8 +10,14 @@ end
function Base.showerror(io::IO, ie::InterfaceError)
printstyled("InterfaceError: "; color=:red)
numstring = isnothing(ie.num) ? "" : " $(ie.num)"
println("test for $(ie.t) :$(ie.name)$(ie.numstring)$(ie.desc) threw a $(typeof(ie.e)) \n For test object $(ie.obj):\n")
Base.showerror(io, e)
println("test for $(ie.t) :$(ie.name)$(numstring)$(ie.desc) threw a $(typeof(ie.e)) \n For test object $(ie.obj):\n")
Base.showerror(io, ie.e)
end

# Wrap objects so we don't get confused iterating
# inside the objects themselves during tests.
struct TestObjectWrapper{O}
objects::O
end

Base.iterate(tow::TestObjectWrapper, args...) = iterate(tow.objects, args...)
Expand All @@ -34,7 +34,6 @@ function check_coherent_types(O::Type, obj)
throw(ArgumentError("""Each tested object must either be an instance of `$O` or an instance of `Arguments` whose field types include at least one subtype of `$O`. You provided a `$(typeof(obj))` instead. """))
end
end

function check_coherent_types(O::Type, tow::TestObjectWrapper)
for obj in tow
check_coherent_types(O::Type, obj)
Expand Down
Loading