Properly parse spaced lists

This commit is contained in:
ConnorSkees 2020-03-19 21:40:36 -04:00
parent 3919e92dcb
commit 8a811dae9e
5 changed files with 37 additions and 18 deletions

View File

@ -123,7 +123,13 @@ impl Value {
Ok(x) => x, Ok(x) => x,
Err(_) => return Ok(left), Err(_) => return Ok(left),
}; };
Ok(Value::List(vec![left, right], ListSeparator::Space)) if let Value::List(v, ListSeparator::Space) = right {
let mut v2 = vec![left];
v2.extend(v);
Ok(Value::List(v2, ListSeparator::Space))
} else {
Ok(Value::List(vec![left, right], ListSeparator::Space))
}
} }
} }
} }

View File

@ -86,13 +86,11 @@ test!(
opacity_function_number_unit, opacity_function_number_unit,
"a {\n color: opacity(1px);\n}\n" "a {\n color: opacity(1px);\n}\n"
); );
// blocked on better value parsing test!(
// specifically, this is parsed as a number and a list rgba_one_arg,
// test!( "a {\n color: rgba(1 2 3);\n}\n",
// rgba_one_arg, "a {\n color: #010203;\n}\n"
// "a {\n color: rgba(1 2 3);\n}\n", );
// "a {\n color: #010203;\n}\n"
// );
test!( test!(
rgb_two_args, rgb_two_args,
"a {\n color: rgb(#123, 0);\n}\n", "a {\n color: rgb(#123, 0);\n}\n",

View File

@ -129,11 +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!( 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",
// "a {\n color: list;\n}\n" "a {\n color: list;\n}\n"
// ); );
test!( test!(
type_of_true, type_of_true,
"a {\n color: type-of(true)\n}\n", "a {\n color: type-of(true)\n}\n",
@ -274,11 +274,11 @@ test!(
// "a {\n color: inspect(())\n}\n", // "a {\n color: inspect(())\n}\n",
// "a {\n color: ();\n}\n" // "a {\n color: ();\n}\n"
// ); // );
// test!( test!(
// inspect_spaced_list, inspect_spaced_list,
// "a {\n color: inspect(1 2 3)\n}\n", "a {\n color: inspect(1 2 3)\n}\n",
// "a {\n color: 1 2 3;\n}\n" "a {\n color: 1 2 3;\n}\n"
// ); );
// test!( // test!(
// inspect_comma_list, // inspect_comma_list,
// "a {\n color: inspect(1, 2, 3)\n}\n", // "a {\n color: inspect(1, 2, 3)\n}\n",

View File

@ -169,3 +169,8 @@ test!(
"@mixin a {\n a {\n color: red;\n }\n}\n\n@include a;\n", "@mixin a {\n a {\n color: red;\n }\n}\n\n@include a;\n",
"a {\n color: red;\n}\n" "a {\n color: red;\n}\n"
); );
test!(
include_list,
"@mixin foo($x) {\n color: $x;\n}\na {\n @include foo(0px 0px 0px 0px #ef8086 inset !important);\n}\n",
"a {\n color: 0px 0px 0px 0px #ef8086 inset !important;\n}\n"
);

View File

@ -463,3 +463,13 @@ test!(
"a {\n color: (a b) - (1 2);\n}\n", "a {\n color: (a b) - (1 2);\n}\n",
"a {\n color: a b-1 2;\n}\n" "a {\n color: a b-1 2;\n}\n"
); );
test!(
length_of_list_as_var,
"$a: 1 2 3 4 5;a {\n color: length($a);\n}\n",
"a {\n color: 5;\n}\n"
);
test!(
length_of_list,
"a {\n color: length(1 2 3 4 5);\n}\n",
"a {\n color: 5;\n}\n"
);