map-keys() returns a comma separated list

This commit is contained in:
ConnorSkees 2020-03-30 16:14:42 -04:00
parent 5e20f57ee0
commit 3621363e0e
2 changed files with 12 additions and 2 deletions

View File

@ -2,7 +2,7 @@ use std::collections::HashMap;
use super::Builtin; use super::Builtin;
use crate::common::{Brackets, ListSeparator}; use crate::common::{Brackets, ListSeparator};
use crate::value::{Value, SassMap}; use crate::value::{SassMap, Value};
pub(crate) fn register(f: &mut HashMap<String, Builtin>) { pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
f.insert( f.insert(
@ -42,7 +42,7 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
}; };
Ok(Value::List( Ok(Value::List(
map.keys(), map.keys(),
ListSeparator::Space, ListSeparator::Comma,
Brackets::None, Brackets::None,
)) ))
}), }),

View File

@ -35,6 +35,16 @@ test!(
"a {\n color: map-keys((a: b));\n}\n", "a {\n color: map-keys((a: b));\n}\n",
"a {\n color: a;\n}\n" "a {\n color: a;\n}\n"
); );
test!(
map_keys_are_comma_separated,
"a {\n color: map-keys((a: b, c: d));\n}\n",
"a {\n color: a, c;\n}\n"
);
test!(
map_keys_empty,
"a {\n color: inspect(map-keys(()));\n}\n",
"a {\n color: ();\n}\n"
);
error!( error!(
map_keys_non_map, map_keys_non_map,
"a {\n color: map-keys(foo);\n}\n", "Error: $map: foo is not a map." "a {\n color: map-keys(foo);\n}\n", "Error: $map: foo is not a map."