handle maps in join()

This commit is contained in:
ConnorSkees 2020-04-02 18:23:57 -04:00
parent a9230b7877
commit 31a19b5ecb
2 changed files with 7 additions and 0 deletions

View File

@ -149,10 +149,12 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
max_args!(args, 4); max_args!(args, 4);
let (mut list1, sep1, brackets) = match arg!(args, 0, "list1") { let (mut list1, sep1, brackets) = match arg!(args, 0, "list1") {
Value::List(v, sep, brackets) => (v, sep, brackets), Value::List(v, sep, brackets) => (v, sep, brackets),
Value::Map(m) => (m.entries(), ListSeparator::Comma, Brackets::None),
v => (vec![v], ListSeparator::Space, Brackets::None), v => (vec![v], ListSeparator::Space, Brackets::None),
}; };
let (list2, sep2) = match arg!(args, 1, "list2") { let (list2, sep2) = match arg!(args, 1, "list2") {
Value::List(v, sep, ..) => (v, sep), Value::List(v, sep, ..) => (v, sep),
Value::Map(m) => (m.entries(), ListSeparator::Comma),
v => (vec![v], ListSeparator::Space), v => (vec![v], ListSeparator::Space),
}; };
let sep = match arg!( let sep = match arg!(

View File

@ -217,6 +217,11 @@ test!(
"a {\n color: join((a,), (b,));\n}\n", "a {\n color: join((a,), (b,));\n}\n",
"a {\n color: a, b;\n}\n" "a {\n color: a, b;\n}\n"
); );
test!(
join_two_maps,
"a {\n color: join((c: d, e: f), (g: h, i: j));\n}\n",
"a {\n color: c d, e f, g h, i j;\n}\n"
);
test!(bracketed_ident, "a {\n color: [a];\n}\n"); test!(bracketed_ident, "a {\n color: [a];\n}\n");
test!(bracketed_space_list, "a {\n color: [a b];\n}\n"); test!(bracketed_space_list, "a {\n color: [a b];\n}\n");
test!(bracketed_comma_list, "a {\n color: [a, b];\n}\n"); test!(bracketed_comma_list, "a {\n color: [a, b];\n}\n");