From bf98382b0bcfc358270ff6b530df8e5db9cd89d0 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sat, 8 Feb 2020 18:51:29 -0500 Subject: [PATCH] Improve alpha/opacity function tests --- src/value/number.rs | 4 ++++ tests/color.rs | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/value/number.rs b/src/value/number.rs index 841d03b..5a497aa 100644 --- a/src/value/number.rs +++ b/src/value/number.rs @@ -44,6 +44,10 @@ impl Display for Number { break; } } + if frac != BigRational::from_integer(BigInt::from(0)) { + write!(f, "{}", (frac * BigRational::from_integer(BigInt::from(10))).round().to_integer())?; + } + } Ok(()) } diff --git a/tests/color.rs b/tests/color.rs index f104b05..ff23f69 100644 --- a/tests/color.rs +++ b/tests/color.rs @@ -49,5 +49,10 @@ test!( test!( alpha_function_4_hex, "a {\n color: alpha(#0123);\n}\n", - "a {\n color: .25;\n}\n" + "a {\n color: 0.2;\n}\n" +); +test!( + alpha_function_named_color, + "a {\n color: alpha(red);\n}\n", + "a {\n color: 1;\n}\n" );