maps in set-nth()

This commit is contained in:
ConnorSkees 2020-04-02 15:28:35 -04:00
parent cba2b12771
commit c7fdf8eef3
2 changed files with 6 additions and 0 deletions

View File

@ -78,6 +78,7 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
max_args!(args, 3);
let (mut list, sep) = match arg!(args, 0, "list") {
Value::List(v, sep, ..) => (v, sep),
Value::Map(m) => (m.entries(), ListSeparator::Comma),
v => (vec![v], ListSeparator::Space),
};
let n = match arg!(args, 1, "n") {

View File

@ -83,6 +83,11 @@ test!(
"a {\n color: set-nth((a, b, c), 1, e);\n}\n",
"a {\n color: e, b, c;\n}\n"
);
test!(
set_nth_map,
"a {\n color: set-nth((c: d, e: f, g: h), 2, i);\n}\n",
"a {\n color: c d, i, g h;\n}\n"
);
test!(
append_space_separated,
"a {\n color: append(a b, c);\n}\n",