Skip to content

Commit 131aee5

Browse files
authored
Merge pull request #2 from hobovsky/cw-reporter
2 parents 42f7d84 + e638599 commit 131aee5

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/FactCheck.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ end
8383

8484
# Define printing functions for the result types
8585
function Base.show(io::IO, f::Failure)
86-
println(io, "\n<IT::>", f.meta.msg != nothing ? "$(f.meta.msg)" : format_fact(f.expr))
87-
println(io, "\n<FAILED::>Test Failed")
86+
println(io, "\n<IT::>", replace_lf(format_fact(f.expr)))
87+
print(io, "\n<FAILED::>", replace_lf(f.meta.msg != nothing ? "$(f.meta.msg)" : "Test Failed"))
8888
if f.fact_type == :fact_throws
8989
# @fact_throws didn't get an error, or the right type of error
9090
if f.rhs != :fact_throws_noerror
91-
println(io, "\tExpected: ", f.rhs[1])
92-
println(io, "\tOccurred: ", f.rhs[2])
91+
print(io, "<:LF:> Expected: ", f.rhs[1])
92+
print(io, "<:LF:> Occurred: ", f.rhs[2])
9393
end
9494
elseif f.fact_type == :fact
9595
# @fact didn't get the right result
@@ -98,34 +98,34 @@ function Base.show(io::IO, f::Failure)
9898
# Fancy helper fact
9999
fcFunc = _factcheck_function(args[2])
100100
if haskey(FACTCHECK_FUN_NAMES, fcFunc)
101-
println(io, replace_lf(string("\tExpected: ", sprint(show, f.lhs), " ", FACTCHECK_FUN_NAMES[fcFunc], " ", sprint(show, f.rhs))))
101+
print(io, replace_lf(string("<:LF:> Expected: ", sprint(show, f.lhs), " ", FACTCHECK_FUN_NAMES[fcFunc], " ", sprint(show, f.rhs))))
102102
else
103-
println(io, replace_lf(string("\tExpected: ", sprint(show, f.lhs), " --> ", fcFunc, "(", sprint(show, f.rhs), ")")))
103+
print(io, replace_lf(string("<:LF:> Expected: ", sprint(show, f.lhs), " --> ", fcFunc, "(", sprint(show, f.rhs), ")")))
104104
end
105105
else
106106
# Normal equality-test-style fact
107-
println(io, replace_lf(string("\tExpected: ", sprint(show, f.rhs), "\n", "\tOccurred: ", sprint(show, f.lhs))))
107+
print(io, replace_lf(string("<:LF:> Expected: ", sprint(show, f.rhs), "<:LF:> Occurred: ", sprint(show, f.lhs))))
108108
end
109109
else
110110
error("Unknown fact type: ", f.fact_type)
111111
end
112-
println(io, "\n<COMPLETEDIN::>")
112+
println(io, "\n\n<COMPLETEDIN::>")
113113
end
114114

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

122122
function Base.show(io::IO, s::Success)
123123
if s.rhs == :fact_throws_error
124-
println(io, "\n<IT::>", s.meta.msg != nothing ? "$(s.meta.msg)" : "Throws Error")
124+
println(io, "\n<IT::>", replace_lf(s.meta.msg != nothing ? "$(s.meta.msg)" : "Throws Error"))
125125
println(io, "\n<PASSED::>Test Passed")
126126
println(io, "\n<COMPLETEDIN::>")
127127
else
128-
println(io, "\n<IT::>", s.meta.msg != nothing ? "$(s.meta.msg)" : format_fact(s.expr))
128+
println(io, "\n<IT::>", replace_lf(s.meta.msg != nothing ? "$(s.meta.msg)" : format_fact(s.expr)))
129129
println(io, "\n<PASSED::>Test Passed")
130130
println(io, "\n<COMPLETEDIN::>")
131131
end
@@ -360,7 +360,7 @@ end
360360
# environment, which means constructing a `TestSuite`, generating
361361
# and registering test handlers, and reporting results.
362362
function facts(f::Function, desc)
363-
println(string("\n<DESCRIBE::>", desc == nothing ? "Unnamed Facts" : "$(desc)"))
363+
println(string("\n<DESCRIBE::>", replace_lf(desc == nothing ? "Unnamed Facts" : "$(desc)")))
364364
handler = make_handler(TestSuite(nothing, desc))
365365
push!(handlers, handler)
366366
f()
@@ -373,7 +373,7 @@ facts(f::Function) = facts(f, nothing)
373373
# Executes a battery of tests in some descriptive context, intended
374374
# for use inside of `facts`. Displays the string in default mode.
375375
function context(f::Function, desc::AbstractString)
376-
println(string("\n<DESCRIBE::>", desc == "" ? "Unnamed Context" : desc))
376+
println(string("\n<DESCRIBE::>", replace_lf(desc == "" ? "Unnamed Context" : desc)))
377377
push!(contexts, desc)
378378
try
379379
f()

0 commit comments

Comments
 (0)