Show counter examples in green when property is expected to fail.
This commit is contained in:
parent
3e922c0a52
commit
fbeb611e5f
|
@ -331,17 +331,35 @@ fn fmt_test(
|
||||||
..
|
..
|
||||||
}) = result
|
}) = result
|
||||||
{
|
{
|
||||||
|
let is_expected_failure = result.is_success();
|
||||||
|
|
||||||
test = format!(
|
test = format!(
|
||||||
"{test}\n{}\n{}\n",
|
"{test}\n{}\n{}\n",
|
||||||
|
if is_expected_failure {
|
||||||
|
"★ counterexample"
|
||||||
|
.if_supports_color(Stderr, |s| s.green())
|
||||||
|
.if_supports_color(Stderr, |s| s.bold())
|
||||||
|
.to_string()
|
||||||
|
} else {
|
||||||
"× counterexample"
|
"× counterexample"
|
||||||
.if_supports_color(Stderr, |s| s.red())
|
.if_supports_color(Stderr, |s| s.red())
|
||||||
.if_supports_color(Stderr, |s| s.bold()),
|
.if_supports_color(Stderr, |s| s.bold())
|
||||||
|
.to_string()
|
||||||
|
},
|
||||||
&Formatter::new()
|
&Formatter::new()
|
||||||
.expr(counterexample, false)
|
.expr(counterexample, false)
|
||||||
.to_pretty_string(60)
|
.to_pretty_string(60)
|
||||||
.lines()
|
.lines()
|
||||||
.map(|line| {
|
.map(|line| {
|
||||||
format!("{} {}", "│".if_supports_color(Stderr, |s| s.red()), line)
|
format!(
|
||||||
|
"{} {}",
|
||||||
|
"│".if_supports_color(Stderr, |s| if is_expected_failure {
|
||||||
|
s.green().to_string()
|
||||||
|
} else {
|
||||||
|
s.red().to_string()
|
||||||
|
}),
|
||||||
|
line
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join("\n")
|
.join("\n")
|
||||||
|
|
Loading…
Reference in New Issue