diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-01-15 15:43:59 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-01-15 15:43:59 +0100 |
| commit | 0f0416054f263b80ccec1a463ce4ab20913bdf71 (patch) | |
| tree | 09cc642c361327c386e88e89f81f512248d59514 /src/eval | |
| parent | 469d78d610085044845f0fba462f1d8170b62cd4 (diff) | |
Move value tests + smarter number formatting 🔢
Diffstat (limited to 'src/eval')
| -rw-r--r-- | src/eval/value.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/eval/value.rs b/src/eval/value.rs index 13548c87..20cc457c 100644 --- a/src/eval/value.rs +++ b/src/eval/value.rs @@ -116,8 +116,8 @@ impl Pretty for Value { match self { Value::None => p.push_str("none"), Value::Bool(v) => write!(p, "{}", v).unwrap(), - Value::Int(v) => write!(p, "{}", v).unwrap(), - Value::Float(v) => write!(p, "{}", v).unwrap(), + Value::Int(v) => p.push_str(itoa::Buffer::new().format(*v)), + Value::Float(v) => p.push_str(ryu::Buffer::new().format(*v)), Value::Length(v) => write!(p, "{}", v).unwrap(), Value::Angle(v) => write!(p, "{}", v).unwrap(), Value::Relative(v) => write!(p, "{}", v).unwrap(), @@ -521,9 +521,9 @@ mod tests { test_pretty(false, "false"); test_pretty(12.4, "12.4"); test_pretty(Length::pt(5.5), "5.5pt"); - test_pretty(Angle::deg(90.0), "90deg"); - test_pretty(Relative::ONE / 2.0, "50%"); - test_pretty(Relative::new(0.3) + Length::cm(2.0), "30% + 2cm"); + test_pretty(Angle::deg(90.0), "90.0deg"); + test_pretty(Relative::ONE / 2.0, "50.0%"); + test_pretty(Relative::new(0.3) + Length::cm(2.0), "30.0% + 2.0cm"); test_pretty(Color::Rgba(RgbaColor::new(1, 1, 1, 0xff)), "#010101"); test_pretty("hello", r#""hello""#); test_pretty(vec![Spanned::zero(Node::Strong)], "[*]"); |
