Handle empty lists ()

This commit is contained in:
ConnorSkees 2020-03-20 20:01:57 -04:00
parent b0aff089aa
commit 87462490ac
3 changed files with 19 additions and 0 deletions

View File

@ -191,6 +191,10 @@ impl Value {
} }
TokenKind::Symbol(Symbol::OpenParen) => { TokenKind::Symbol(Symbol::OpenParen) => {
devour_whitespace_or_comment(toks); devour_whitespace_or_comment(toks);
if toks.peek().unwrap().is_symbol(Symbol::CloseParen) {
toks.next();
return Ok(Value::List(Vec::new(), ListSeparator::Space));
}
let val = Self::from_tokens(toks, scope, super_selector)?; let val = Self::from_tokens(toks, scope, super_selector)?;
assert_eq!( assert_eq!(
toks.next().unwrap().kind, toks.next().unwrap().kind,

View File

@ -105,3 +105,13 @@ test!(
"a {\n color: append((a, b), c, space);\n}\n", "a {\n color: append((a, b), c, space);\n}\n",
"a {\n color: a b c;\n}\n" "a {\n color: a b c;\n}\n"
); );
test!(
list_separator_empty,
"a {\n color: list-separator(());\n}\n",
"a {\n color: space;\n}\n"
);
test!(
append_empty,
"a {\n color: append((), a);\n}\n",
"a {\n color: a;\n}\n"
);

View File

@ -129,6 +129,11 @@ test!(
"a {\n color: type-of(red)\n}\n", "a {\n color: type-of(red)\n}\n",
"a {\n color: color;\n}\n" "a {\n color: color;\n}\n"
); );
test!(
type_of_empty_list,
"a {\n color: type-of(())\n}\n",
"a {\n color: list;\n}\n"
);
test!( test!(
type_of_spaced_list, type_of_spaced_list,
"a {\n color: type-of(1 2 3)\n}\n", "a {\n color: type-of(1 2 3)\n}\n",