Skip to content

Conversation

@hobovsky
Copy link

@hobovsky hobovsky commented Mar 16, 2023

Code:

facts("Compare passing and failing") do
  context("With custom message") do
    @fact 7 --> 7 "7 is 7"
    @fact 7 --> 13 "13 is 13"
  end
  context("Without custom message") do
    @fact 7 --> 7
    @fact 7 --> 13
  end
  context("@fact_throws with custom message") do
    @fact_throws TypeError typeassert(1.0, Int) "Expected error not thrown"
    @fact_throws TypeError typeassert(1, Int) "Expected error not thrown"
  end      
  context("@fact_throws without custom message") do
    @fact_throws TypeError typeassert(1.0, Int)
    @fact_throws TypeError typeassert(1, Int)
  end    
end

Current Codewars reporter:

image

Proposed reporter:

image

@kazk
Copy link
Member

kazk commented Mar 16, 2023

Can you also update Error?

function Base.show(io::IO, e::Error)
println(io, "\n<IT::>", replace_lf(e.meta.msg != nothing ? "$(e.meta.msg)" : format_fact(e.expr)))
println(io, "\n<ERROR::>", replace_lf(sprint(showerror, e.err)))
println(io, "\n<LOG::-Stack trace>", replace_lf(sprint(showerror, e.err, e.backtrace)))
println(io, "\n<COMPLETEDIN::>")
end

@hobovsky
Copy link
Author

hobovsky commented Mar 16, 2023

I pushed a proposal:

  • Title of IT:: is a formatted expression, just like for other ITs
  • Message of ERROR:: is a meta message if provided, otherwise a formatted exception object like currently. TBH I do not know how to test this branch because I do not know how to put a message in the e.meta.msg field :( I added test facts("Errors") and I verified it goes through the new branch.
  • And without change here, collapsible panel with a printed exception object with stacktrace.

Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants