add tests for bools and important
plus quoted string
This commit is contained in:
parent
cb1eecde74
commit
d9d9777467
@ -174,14 +174,25 @@ impl<'a, 'b: 'a> ValueVisitor<'a, 'b> {
|
||||
)
|
||||
.into())
|
||||
}
|
||||
Value::Important | Value::True | Value::False => match right {
|
||||
Value::True | Value::False => match right {
|
||||
Value::String(s, QuoteKind::Quoted) => Value::String(
|
||||
format!("{}{}", left.to_css_string(self.span)?, s),
|
||||
QuoteKind::Quoted,
|
||||
),
|
||||
Value::Null => {
|
||||
Value::String(left.to_css_string(self.span)?.into_owned(), QuoteKind::None)
|
||||
}
|
||||
_ => Value::String(
|
||||
format!(
|
||||
"{}{}",
|
||||
left.to_css_string(self.span)?,
|
||||
right.to_css_string(self.span)?
|
||||
),
|
||||
QuoteKind::None,
|
||||
),
|
||||
},
|
||||
Value::Important => match right {
|
||||
Value::String(s, ..) => Value::String(
|
||||
format!("{}{}", left.to_css_string(self.span)?, s),
|
||||
QuoteKind::None,
|
||||
),
|
||||
_ => Value::String(
|
||||
format!(
|
||||
"{}{}",
|
||||
|
@ -161,11 +161,41 @@ test!(
|
||||
"a {\n color: true + false;\n}\n",
|
||||
"a {\n color: truefalse;\n}\n"
|
||||
);
|
||||
test!(
|
||||
true_plus_dblquoted,
|
||||
"a {\n color: true + \"foo\";\n}\n",
|
||||
"a {\n color: \"truefoo\";\n}\n"
|
||||
);
|
||||
test!(
|
||||
false_plus_dblquoted,
|
||||
"a {\n color: false + \"foo\";\n}\n",
|
||||
"a {\n color: \"falsefoo\";\n}\n"
|
||||
);
|
||||
test!(
|
||||
true_plus_unquoted,
|
||||
"a {\n color: true + foo;\n}\n",
|
||||
"a {\n color: truefoo;\n}\n"
|
||||
);
|
||||
test!(
|
||||
false_plus_unquoted,
|
||||
"a {\n color: false + foo;\n}\n",
|
||||
"a {\n color: falsefoo;\n}\n"
|
||||
);
|
||||
test!(
|
||||
true_plus_null,
|
||||
"a {\n color: true + null;\n}\n",
|
||||
"a {\n color: true;\n}\n"
|
||||
);
|
||||
test!(
|
||||
false_plus_null,
|
||||
"a {\n color: false + null;\n}\n",
|
||||
"a {\n color: false;\n}\n"
|
||||
);
|
||||
test!(
|
||||
true_plus_null_is_string,
|
||||
"a {\n color: type-of(true + null);\n}\n",
|
||||
"a {\n color: string;\n}\n"
|
||||
);
|
||||
test!(
|
||||
false_plus_null_is_string,
|
||||
"a {\n color: type-of(false + null);\n}\n",
|
||||
@ -297,6 +327,21 @@ test!(
|
||||
"a {\n color: foo + red;\n}\n",
|
||||
"a {\n color: foored;\n}\n"
|
||||
);
|
||||
test!(
|
||||
important_plus_dblquoted,
|
||||
"a {\n color: !important + \"foo\";\n}\n",
|
||||
"a {\n color: !importantfoo;\n}\n"
|
||||
);
|
||||
test!(
|
||||
important_plus_null,
|
||||
"a {\n color: !important + null;\n}\n",
|
||||
"a {\n color: !important;\n}\n"
|
||||
);
|
||||
test!(
|
||||
important_plus_unquoted,
|
||||
"a {\n color: !important + foo;\n}\n",
|
||||
"a {\n color: !importantfoo;\n}\n"
|
||||
);
|
||||
error!(
|
||||
map_lhs_add,
|
||||
"a {color: (a: b) + 1;}", "Error: (a: b) isn't a valid CSS value."
|
||||
|
Loading…
x
Reference in New Issue
Block a user