From 87462490ac6609b91465e695d157ebdc393915b4 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Fri, 20 Mar 2020 20:01:57 -0400 Subject: [PATCH] Handle empty lists `()` --- src/value/parse.rs | 4 ++++ tests/list.rs | 10 ++++++++++ tests/meta.rs | 5 +++++ 3 files changed, 19 insertions(+) diff --git a/src/value/parse.rs b/src/value/parse.rs index 525ea25..7912e58 100644 --- a/src/value/parse.rs +++ b/src/value/parse.rs @@ -191,6 +191,10 @@ impl Value { } TokenKind::Symbol(Symbol::OpenParen) => { 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)?; assert_eq!( toks.next().unwrap().kind, diff --git a/tests/list.rs b/tests/list.rs index 947f5c8..5bd01d0 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -105,3 +105,13 @@ test!( "a {\n color: append((a, b), c, space);\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" +); diff --git a/tests/meta.rs b/tests/meta.rs index d5874ab..d40458b 100644 --- a/tests/meta.rs +++ b/tests/meta.rs @@ -129,6 +129,11 @@ test!( "a {\n color: type-of(red)\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!( type_of_spaced_list, "a {\n color: type-of(1 2 3)\n}\n",