inspect comma separated list of comma separated lists

This commit is contained in:
ConnorSkees 2020-04-20 03:07:02 -04:00
parent 715f6fb94a
commit 9790846c99
2 changed files with 27 additions and 0 deletions

View File

@ -273,6 +273,22 @@ impl Value {
ListSeparator::Comma => format!("[{},]", v[0].inspect(span)?),
},
},
Self::List(vals, sep, brackets) => match brackets {
Brackets::None => format!(
"{}",
vals.iter()
.map(|x| x.inspect(span))
.collect::<SassResult<Vec<String>>>()?
.join(sep.as_str()),
),
Brackets::Bracketed => format!(
"[{}]",
vals.iter()
.map(|x| x.inspect(span))
.collect::<SassResult<Vec<String>>>()?
.join(sep.as_str()),
),
},
Value::Function(f) => format!("get-function(\"{}\")", f.name()),
Value::Null => "null".to_string(),
Value::Map(map) => format!(
@ -286,6 +302,7 @@ impl Value {
.collect::<SassResult<Vec<String>>>()?
.join(", ")
),
Value::Paren(v) => format!("({})", v.inspect(span)?),
v => v.to_css_string(span)?,
})
}

View File

@ -259,6 +259,16 @@ test!(
"a {\n color: inspect(append((), 1, space));\n}\n",
"a {\n color: 1;\n}\n"
);
test!(
inspect_list_of_empty_list,
"a {\n color: inspect(((), ()));\n}\n",
"a {\n color: (), ();\n}\n"
);
test!(
inspect_comma_separated_list_of_comma_separated_lists,
"a {\n color: inspect([(1, 2), (3, 4)]);\n}\n",
"a {\n color: [(1, 2), (3, 4)];\n}\n"
);
test!(
variable_does_exist,
"$a: red; a {\n color: variable-exists(a)\n}\n",