add tests for numbers plus !important, colors, and arglists

This commit is contained in:
Connor Skees 2020-08-19 04:14:49 -04:00
parent d9d9777467
commit 0d7208ccf0
2 changed files with 30 additions and 6 deletions

View File

@ -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 \"{}{} + {}\".",

View File

@ -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",