Handle quotes in feature-exists

This commit is contained in:
ConnorSkees 2020-02-03 07:27:57 -05:00
parent f82f1f3eee
commit e57a189c77
2 changed files with 21 additions and 1 deletions

View File

@ -16,7 +16,7 @@ pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
});
decl!(f "feature-exists", |args| {
let feature: &Value = arg!(args, 0, "feature");
match feature.to_string().as_str() {
match feature.clone().unquote().to_string().as_str() {
// A local variable will shadow a global variable unless
// `!global` is used.
"global-variable-shadowing" => Some(Value::False),

View File

@ -18,3 +18,23 @@ test!(
"a {\n color: if(false, 1, 2);\n}\n",
"a {\n color: 2;\n}\n"
);
test!(
feature_exists_at_error_dbl_quoted,
"a {\n color: feature-exists(\"at-error\")\n}\n",
"a {\n color: true;\n}\n"
);
test!(
feature_exists_at_error_sgl_quoted,
"a {\n color: feature-exists('at-error')\n}\n",
"a {\n color: true;\n}\n"
);
test!(
feature_exists_at_error_no_quotes,
"a {\n color: feature-exists(at-error)\n}\n",
"a {\n color: true;\n}\n"
);
test!(
feature_exists_at_error_named_arg,
"a {\n color: feature-exists($feature: at-error)\n}\n",
"a {\n color: true;\n}\n"
);