diff --git a/src/value.rs b/src/value.rs index 6f90035..c0fd0e1 100644 --- a/src/value.rs +++ b/src/value.rs @@ -83,10 +83,18 @@ impl Add for Value { fn add(self, other: Self) -> Self { match self { - // Self::Important => todo!(), - // Self::True => todo!(), - // Self::False => todo!(), - // Self::Null => todo!(), + Self::Important + | Self::True + | Self::False => match other { + Self::Ident(s, QuoteKind::Double) + | Self::Ident(s, QuoteKind::Single) => Value::Ident(format!("{}{}", self, s), QuoteKind::Double), + Self::Null => Value::Ident(self.to_string(), QuoteKind::None), + _ => Value::Ident(format!("{}{}", self, other), QuoteKind::None) + }, + Self::Null => match other { + Self::Null => Self::Null, + _ => Value::Ident(format!("{}{}", self, other), QuoteKind::None) + }, Self::Dimension(num, unit) => match other { Self::Dimension(num2, unit2) => Value::Dimension(num + num2, unit), _ => todo!(), @@ -234,7 +242,6 @@ impl Value { Value::Null => "null", Value::BinaryOp(..) => self.eval().kind(), _ => "unknown", - } } diff --git a/tests/values.rs b/tests/values.rs index 80a5d2e..4756263 100644 --- a/tests/values.rs +++ b/tests/values.rs @@ -164,6 +164,21 @@ test!( "a {\n color: 'red' + 1px;\n}\n", "a {\n color: \"red1px\";\n}\n" ); +test!( + adds_true_false, + "a {\n color: true + false;\n}\n", + "a {\n color: truefalse;\n}\n" +); +test!( + adds_false_null_is_string, + "a {\n color: if(false+null, 1, 2);\n}\n", + "a {\n color: 1;\n}\n" +); +test!( + adds_null_num_is_string, + "a {\n color: null + 1;\n}\n", + "a {\n color: 1;\n}\n" +); test!( subs_idents, "a {\n color: red - blue;\n}\n",