From 0d7208ccf0b1335032ef681ceae45c0fe6a1ced2 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Wed, 19 Aug 2020 04:14:49 -0400 Subject: [PATCH] add tests for numbers plus `!important`, colors, and arglists --- src/parse/value/eval.rs | 8 ++++++-- tests/addition.rs | 28 ++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/parse/value/eval.rs b/src/parse/value/eval.rs index a2d49b3..af47dbf 100644 --- a/src/parse/value/eval.rs +++ b/src/parse/value/eval.rs @@ -232,7 +232,11 @@ impl<'a, 'b: 'a> ValueVisitor<'a, 'b> { } Value::String(s, q) => Value::String(format!("{}{}{}", num, unit, s), q), Value::Null => Value::String(format!("{}{}", num, unit), QuoteKind::None), - Value::True | Value::False | Value::List(..) => Value::String( + Value::True + | Value::False + | Value::List(..) + | Value::Important + | Value::ArgList(..) => Value::String( format!("{}{}{}", num, unit, right.to_css_string(self.span)?), QuoteKind::None, ), @@ -243,7 +247,7 @@ impl<'a, 'b: 'a> ValueVisitor<'a, 'b> { ) .into()) } - _ => { + Value::Color(..) => { return Err(( format!( "Undefined operation \"{}{} + {}\".", diff --git a/tests/addition.rs b/tests/addition.rs index 8ebe0a8..153ca34 100644 --- a/tests/addition.rs +++ b/tests/addition.rs @@ -212,7 +212,7 @@ test!( "a {\n color: string;\n}\n" ); test!( - num_plus_list, + number_plus_list, "a {\n color: 1 + (2 3);\n}\n", "a {\n color: 12 3;\n}\n" ); @@ -282,20 +282,40 @@ test!( "a {\n color: foo#fff;\n}\n" ); test!( - num_plus_true, + number_plus_true, "a {\n color: 1 + true;\n}\n", "a {\n color: 1true;\n}\n" ); test!( - num_plus_false, + number_plus_false, "a {\n color: 1 + false;\n}\n", "a {\n color: 1false;\n}\n" ); test!( - num_plus_unary_not, + number_plus_unary_not, "a {\n color: 1 + not 2;\n}\n", "a {\n color: 1false;\n}\n" ); +test!( + number_plus_important, + "a {\n color: 1 + !important;\n}\n", + "a {\n color: 1!important;\n}\n" +); +test!( + number_plus_arglist, + "@function foo($a...) { + @return 1+$a; + } + + a { + color: foo(a, b, c); + }", + "a {\n color: 1a, b, c;\n}\n" +); +error!( + number_plus_named_color, + "a {\n color: 1 + red;\n}\n", "Error: Undefined operation \"1 + red\"." +); test!( double_plus, "a {\n color: 1 ++ 2;\n}\n",