From 18ab56eaf3edbfcc27b0a1b01f713802203e8721 Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Tue, 4 Oct 2022 15:05:11 +0000 Subject: [PATCH] Fixing the output for the test diffs in PRs (#2320) This PR fixes PR comments where negative numbers from 100 to 999 would be shown as `-,999` instead of `-999` --- boa_tester/src/results.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/boa_tester/src/results.rs b/boa_tester/src/results.rs index 622a45682f..42929eba4b 100644 --- a/boa_tester/src/results.rs +++ b/boa_tester/src/results.rs @@ -250,7 +250,7 @@ pub(crate) fn compare_results(base: &Path, new: &Path, markdown: bool) { fn pretty_int(i: isize) -> String { let mut res = String::new(); - for (idx, val) in i.to_string().chars().rev().enumerate() { + for (idx, val) in i.abs().to_string().chars().rev().enumerate() { if idx != 0 && idx % 3 == 0 { res.insert(0, ','); } @@ -264,7 +264,13 @@ pub(crate) fn compare_results(base: &Path, new: &Path, markdown: bool) { format!( "{}{}{}{}", if diff == 0 { "" } else { "**" }, - if diff > 0 { "+" } else { "" }, + if diff.is_positive() { + "+" + } else if diff.is_negative() { + "-" + } else { + "" + }, pretty_int(diff), if diff == 0 { "" } else { "**" } )